Skip to content

Commit 4b0b063

Browse files
committed
Merged PR 280: feat(iot-ops): add Bicep deployment scripts support for Azure Key Vault integration
This PR introduces significant enhancements to Bicep blueprint modules, deployment script management, and Key Vault integration for Azure IoT Operations. The changes include new blueprint modules, expanded parameters, improved outputs, and refactored resource and secret management for deployment automation and security. - **feat(blueprints)**(_bicep_): added new blueprint modules for only-cloud-single-node-cluster and only-edge-iot-ops - Introduced `blueprints/only-cloud-single-node-cluster/bicep/main.bicep` and `blueprints/only-edge-iot-ops/bicep/main.bicep` for targeted deployments - Added corresponding `types.core.bicep` files for type safety and parameter consistency - **feat(blueprints)**(_bicep_): expanded parameters and outputs in full-single-node-cluster and full-multi-node-cluster - Added IoT Operations, trust, Key Vault, and deployment script parameters - Enhanced outputs to expose extension, instance, and data flow resource details - **feat(cncf-cluster)**(_bicep_): refactored cluster and Key Vault parameters, improved script and secret handling - Unified and clarified parameters for Arc onboarding, Key Vault, and deployment scripts - Updated modules to use new parameter names and improved environment variable handling - Added support for storing and retrieving deployment and K3s tokens as Key Vault secrets - **feat(security-identity)**(_bicep_): added deployment identity outputs and resources - Created new managed identity for deployment automation - Exposed deployment identity details in outputs - **feat(iot-ops)**(_bicep_): improved deployment script and secret management - Added parameters and logic for deployment scripts and Key Vault integration - Enhanced support for trust issuer and secret sync configuration - **chore**: updated .gitignore to exclude generated PR files - **fix(blueprints)**: enabled event grid and event hub data flows in Terraform blueprints - **chore**: various documentation and linting improvements ## Notes - Several parameters for deployment scripts are currently disabled and set as variables, pending support for AZ CLI 2.71+ in DeploymentScripts (expected post May 4). - The new blueprints allow for more granular deployment scenarios, including cloud-only and edge-only setups. ## Important - Ensure that Key Vault and managed identities are properly provisioned before running deployment scripts. - Review new and updated parameters in blueprint and component modules for required values. ## Follow-up Tasks - Update deployment scripts to leverage enabled parameters once AZ CLI 2.71+ is supported in DeploymentScripts - Review and update documentation for new blueprint usage and parameterization 🚀 - Generated by Copilot Related work items: #447
1 parent 5ecd2a4 commit 4b0b063

File tree

74 files changed

+6242
-1071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+6242
-1071
lines changed

.github/copilot-instructions.md

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,20 @@
11
# Copilot Instructions
22

3-
This is a large multi-faceted repo, so as you work in it, help the user ramp up by:
4-
5-
- Add links and short tips and explanations where it would help the user learn the organization of the repo or the structure of the deployed solution.
6-
- Never guess or assume default options or parameters. Instead ask the user questions needed, provide a suggested set of defaults, but confirm these with the user (with alternatives where appropriate).
7-
8-
## Deploy the Solution (via a Blueprint)
9-
10-
- You can assist deploying the solution by running through the instructions from [the Blueprint README](../blueprints/README.md). (Use this carefully step-by-step and refer back to it as you go). Guidance for running the deployment:
11-
12-
- You will be using the Azure CLI to build a `terraform.tfvars` using Azure CLI to get the required info
13-
- For a learning/sandbox deployment, the 'single-full-cluster' deployment is a good default, but please ask.
14-
- For `resource-prefix` always ask the user what to use here (this ensures multiple deployments in the same RG won't conflict).
15-
- The code in the repo works for a normal deployment. Do not modify any repo files during an assisted deployment. If there are issues with Azure Login/AAD, they are likely config issues.
16-
- If running a CLI operation with an input prompt (e.g. Terraform operation with args that aren't in tf vars), fill these into the CLI so the shell operation doesn't prompt.
17-
18-
## Build a new Component
19-
20-
- Components are defined in the [src](../src/) directory. [Components README](../src/README.md). To create a new component, follow the examples in this folder.
21-
22-
## Build a new Blueprint
23-
24-
- Blueprints are defined in the [blueprints](../blueprints/) directory. [Blueprints README](../blueprints/README.md). Use an existing Blueprint as a starting point, usually [full-single-snode-cluster](../blueprints/full-single-node-cluster/terraform/) and add/remove as needed.
25-
- When building a new Blueprint, use the existing building blocks in `/src`.
26-
27-
## Terraform
28-
29-
- Always do a `terraform plan` before running `apply`.
30-
- Always run `terraform fmt` to maintain consistent code formatting for project files (.gitignored files like tfvars files excluded).
31-
- Organize infrastructure resources into reusable modules.
32-
- Use versioned modules and provider version locks to ensure consistent deployments.
33-
- Use `terraform state` commands to inspect, move, or remove resources in the state when necessary.
34-
- Run `terraform refresh` to ensure that state reflects the current infrastructure.
35-
- When building reusable modules (in the `/src` folder), always write tests in a `tests` directory of the main terraform module.
36-
37-
## Markdown
38-
39-
- Follow Markdown [megalinter](../.mega-linter.yml) rules for all markdown files.
40-
- Use proper header formatting: blank line before and after headers
41-
- Use proper list formatting:
42-
- Use `-` for unordered lists
43-
- Use `1.` for ordered lists
44-
- Use `>` for blockquotes
45-
- Use `*` for emphasis (italics) and `**` for strong emphasis (bold)
46-
- Blank line before and after lists
47-
- Use proper table formatting:
48-
- Include a header row with column names
49-
- Use the `|` character to define columns
50-
- Include a separator row with dashes (e.g., `|------|------|`)
51-
- Tables are exempted from line length limits, but should remain readable
52-
- Use proper code block formatting:
53-
- Use triple backticks (```) for code blocks
54-
- Always specify the language for syntax highlighting (e.g., ` ```hlc `, ` ```python `, ` ```bicep ` and so on)
55-
- Use indentation for nested code blocks
56-
- Blank line before and after code blocks
57-
- The repo uses MARKDOWN_MARKDOWN_TABLE_FORMATTER to automatically format tables
58-
- Follow consistent header formatting with proper spacing (one space after `#`)
59-
- Use ordered lists (`1.`, `2.`, etc.) for sequential steps and unordered lists (`-`) for non-sequential items
60-
- Code blocks should specify the language for proper syntax highlighting
61-
- Links should use reference-style format when referencing the same URL multiple times
62-
- Avoid HTML elements except those explicitly allowed in `.markdownlint.json` (`details` and `summary`)
3+
- You are RESPONSIBLE for ALWAYS reading in AT LEAST 1000+ (thousand) lines at a time for prompt and instruction files.
4+
- You will ALWAYS follow the `prompt-instruction-rules`.
5+
6+
## Prompt and Instruction Rules
7+
8+
<!-- <prompt-instruction-rules> -->
9+
- You will ALWAYS read and follow instructions from ./instructions/general.instructions.md
10+
- You will ALWAYS read and follow instructions from ./instructions/structure.instructions.md
11+
- You will ALWAYS read and follow instructions from ./prompts/getting-started.prompt.md WHEN prompted with anything about getting started or quick start.
12+
- You will ALWAYS read and follow instructions from ./prompts/deploy.prompt.md WHEN prompted with anything about deployment.
13+
- You will ALWAYS read and follow instructions from ./prompts/pr.prompt.md WHEN prompted with anything about pull request generation or pr creation.
14+
- You will ALWAYS read and follow instructions from ./instructions/bicep.instructions.md WHEN prompted with anything about bicep.
15+
- You will ALWAYS read and follow instructions from ./instructions/csharp-tests.instructions.md WHEN prompted with anything about C# tests or csharp tests.
16+
- You will ALWAYS read and follow instructions from ./instructions/csharp.instructions.md WHEN prompted with anything about C# or csharp.
17+
- You will ALWAYS read and follow instructions from ./instructions/markdown.instructions.md WHEN prompted with anything about markdown.
18+
- You will ALWAYS read and follow instructions from ./instructions/python-script.instructions.md WHEN prompted with anything about python.
19+
- You will ALWAYS read and follow instructions from ./instructions/terraform.instructions.md WHEN prompted with anything about terraform.
20+
<!-- </prompt-instruction-rules> -->

.github/prompts/bicep.prompt.md renamed to .github/instructions/bicep.instructions.md

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
# Bicep Infrastructure as Code (IaC) Conventions and Best Practices
1+
---
2+
applyTo: '**/*.bicep*'
3+
---
4+
# Bicep IaC Conventions and Best Practices
25

36
You are an expert in Bicep Infrastructure as Code (IaC) with deep knowledge of Azure resources. When writing or evaluating Bicep code, always follow the conventions in this document.
47

58
## Repository Structure
69

710
This repository is organized with the following key directories:
811

9-
1. **Source Components** (`/src`) - Individual reusable infrastructure components:
12+
1. **Source Components** (`src/`) - Individual reusable infrastructure components:
1013
- `000-cloud/` - Cloud-based resources (Resource Groups, Identity, Storage, etc.)
1114
- `100-edge/` - Edge-based resources (IoT Operations, CNCF clusters, etc.)
1215
- `500-application/` - Application resources and source code
1316
- `900-tools-utilities/` - Tools and utilities (YAML, Helm charts, etc.)
1417

15-
2. **Blueprints** (`/blueprints`) - End-to-end solutions that combine components:
18+
2. **Blueprints** (`blueprints/`) - End-to-end solutions that combine components:
1619
- `full-single-node-cluster/` - Single-node AIO deployment
1720
- `full-multi-node-cluster/` - Multi-node HA AIO deployment
1821
- `only-output-cncf-cluster-script/` - Script-only deployment
@@ -25,7 +28,7 @@ Component Modules are the top-level, standalone modules that provide a specific
2528

2629
**Characteristics of Component Modules:**
2730

28-
- Located directly under a component directory in `/src` (e.g., `/src/100-edge/110-iot-ops/bicep/`)
31+
- Located directly under a component directory in `src/` (e.g., `src/100-edge/110-iot-ops/bicep/`)
2932
- Exposed to be called from **Blueprint** modules
3033
- Represent a complete, self-contained functional unit (e.g., Resource Group, CNCF Cluster, IoT Ops)
3134
- Can use their own Internal Modules but NEVER reference other Component Modules
@@ -36,7 +39,7 @@ Component Modules are the top-level, standalone modules that provide a specific
3639
**Example Component Module path:**
3740

3841
```plain
39-
/src/100-edge/110-iot-ops/bicep/
42+
src/100-edge/110-iot-ops/bicep/
4043
```
4144

4245
### Internal Modules
@@ -45,17 +48,16 @@ Internal Modules are subordinate, reusable modules that are only used within the
4548

4649
**Characteristics of Internal Modules:**
4750

48-
- Located in the `modules` subdirectory of a Component Module (e.g., `/src/100-edge/110-iot-ops/bicep/modules/iot-ops-instance.bicep`)
51+
- Located in the `modules` subdirectory of a Component Module (e.g., `src/100-edge/110-iot-ops/bicep/modules/iot-ops-instance.bicep`)
4952
- NEVER called directly from Blueprints or other Component Modules
50-
- Only called from their parent Component Module
5153
- Implement specific functionality within the scope of their parent Component
5254
- Have narrower scope and focused responsibility
5355
- Include metadata name and description at the top of the file
5456

5557
**Example Internal Module path:**
5658

5759
```plain
58-
/src/100-edge/110-iot-ops/bicep/modules/iot-ops-instance.bicep
60+
src/100-edge/110-iot-ops/bicep/modules/iot-ops-instance.bicep
5961
```
6062

6163
### CI Bicep Directories
@@ -64,7 +66,7 @@ CI Bicep directories are wrapper directories used for CI/CD integration that lev
6466

6567
**Characteristics of CI Bicep Directories:**
6668

67-
- Located at `<component>/ci/bicep/` (e.g., `/src/100-edge/110-iot-ops/ci/bicep/`)
69+
- Located at `<component>/ci/bicep/` (e.g., `src/100-edge/110-iot-ops/ci/bicep/`)
6870
- Contains simple code that calls the parent Component Module with default/test configurations
6971
- Used for individual component testing and verification in CI/CD pipelines
7072
- Acts as a thin wrapper for the component, not setting up test resources
@@ -145,6 +147,39 @@ Each blueprint includes:
145147

146148
## Bicep Coding Conventions
147149

150+
- ALWAYS use the same API version for the same resource, the `@2023-01-31` part is the API version
151+
- ALWAYS use the existing API version for the same resource
152+
- ALWAYS use the latest API version for the same resource, as an example:
153+
- If the following code exists in the codebase:
154+
155+
```bicep
156+
resource sseIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' = {
157+
}
158+
159+
// Somewhere else in the codebase...
160+
resource aioIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
161+
}
162+
```
163+
164+
- Then the code should be updated to the following:
165+
166+
```bicep
167+
resource sseIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' = {
168+
}
169+
170+
// Somewhere else in the codebase...
171+
resource aioIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' = {
172+
}
173+
```
174+
175+
- ALWAYS search the codebase for existing Bicep resources to use as a reference when editing
176+
- WHEN no reference exists, it is important to always use that latest Bicep ARM API reference and version
177+
- Use VS Code's API Tooling for getting the ARM reference and version information
178+
- Fallback to navigating and completely reading in the web pages (excluding images) for the following template, `https://learn.microsoft.com/azure/templates/{provider-namespace}/{resource-type}` for the latest Bicep ARM API reference and version
179+
- e.g., `https://learn.microsoft.com/azure/templates/microsoft.managedidentity/userassignedidentities`
180+
- ALWAYS after making edits, verify VS Codes's information, warnings, and errors for Bicep
181+
- ALWAYS make any and all corrections, if unable, fallback to these prompt instructions
182+
148183
### General Conventions
149184

150185
- ALWAYS use `kebab-case` for file and folder names
@@ -292,7 +327,7 @@ resource example '[email protected]' = if (shouldCreateExample) {
292327
*/
293328
294329
module exampleInternalModule 'modules/example-internal-module.bicep' = {
295-
name: '${deployment().name}-exampleInternalModule'
330+
name: '${deployment().name}-eim0'
296331
params: {
297332
aioPlatformConfig: aioPlatformConfig
298333
common: common
@@ -321,12 +356,12 @@ output storageAccountName string = exampleInternalModule.outputs.storageAccountN
321356

322357
IMPORTANT RULES:
323358

324-
- Component Modules (e.g., `/src/100-edge/110-iot-ops/bicep/`) NEVER reference other Component Modules
359+
- Component Modules (e.g., `src/100-edge/110-iot-ops/bicep/`) NEVER reference other Component Modules
325360
- Component Modules NEVER reference other Component Modules' Internal Modules
326361
- Component Modules ONLY reference their own Internal Modules
327-
- Internal Modules (e.g., `/src/100-edge/110-iot-ops/bicep/modules/iot-ops-instance.bicep`) NEVER reference other Component Modules
362+
- Internal Modules (e.g., `src/100-edge/110-iot-ops/bicep/modules/iot-ops-instance.bicep`) NEVER reference other Component Modules
328363
- Internal Modules NEVER reference other Component Modules' Internal Modules
329-
- Blueprint Modules (e.g., `/blueprints/full-multi-node-cluster/bicep/`) ONLY reference Component Modules, NEVER Internal Modules
364+
- Blueprint Modules (e.g., `blueprints/full-multi-node-cluster/bicep/`) ONLY reference Component Modules, NEVER Internal Modules
330365

331366
### Parameters Conventions
332367

@@ -375,15 +410,15 @@ Example:
375410

376411
```bicep
377412
module roleAssignment 'modules/role-assignment.bicep' = if (shouldAssignKeyVaultRoles) {
378-
name: '${deployment().name}-roleAssignment'
413+
name: '${deployment().name}-ra0'
379414
params: {
380415
keyVaultName: sseKeyVaultName
381416
sseUserAssignedIdentityName: sseIdentityName
382417
}
383418
}
384419
385420
module iotOpsInstance 'modules/iot-ops-instance.bicep' = {
386-
name: '${deployment().name}-iotOpsInstance'
421+
name: '${deployment().name}-ioi1'
387422
params: {
388423
aioDataFlowInstanceConfig: aioDataFlowInstanceConfig
389424
aioExtensionConfig: aioExtensionConfig
@@ -433,7 +468,7 @@ output aioMqBrokerId string = shouldDeployResourceSyncRules ? mqBroker.id : ''
433468
- DO use the safe access operator `.?` when accessing potentially null properties
434469
- DO create default objects with default values for complex types
435470
- DO use conditional deployments with `if` statements for optional resources
436-
- DO use `${deployment().name}` prefix for module names to ensure uniqueness
471+
- DO use `${deployment().name}` prefix for module names and acronym followed by order number for uniqueness
437472
- DO use section headers with `/*` comments to organize your code
438473
- DO include comments for important logic or implementation details
439474
- DO validate inputs when appropriate, especially for security-sensitive parameters
@@ -455,9 +490,9 @@ output aioMqBrokerId string = shouldDeployResourceSyncRules ? mqBroker.id : ''
455490
Before making ANY changes to Bicep code, ask yourself:
456491

457492
- [ ] Am I working on a Component Module, an Internal Module, or a Blueprint?
458-
- Component Module: Located directly under `/src/000-grouping/000-component/bicep/`
459-
- Internal Module: Located under `/src/000-grouping/000-component/bicep/modules/module-name.bicep`
460-
- Blueprint: Located under `/blueprints/blueprint-name/bicep/`
493+
- Component Module: Located directly under `src/000-grouping/000-component/bicep/`
494+
- Internal Module: Located under `src/000-grouping/000-component/bicep/modules/module-name.bicep`
495+
- Blueprint: Located under `blueprints/blueprint-name/bicep/`
461496
- [ ] Am I following the correct file structure for this module type?
462497
- [ ] Will my module references follow the module relationship rules?
463498
- [ ] Are my parameters organized with appropriate groupings?

.github/prompts/csharp-tests.prompt.md renamed to .github/instructions/csharp-tests.instructions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
---
2+
applyTo: '**/*.cs,**/*.csproj'
3+
---
14
# C# (csharp) Tests
25

6+
Only use this section when the prompt is specifically asking for C# tests. This section is only for C# tests and not
7+
for C# code.
38
You are an expert in the latest C#, .NET, and testing. You will always follow common idioms, conventions, and best
49
practices when writing C#. You will always refer to any additional provided prompts on C# (csharp) for creating code.
510

.github/prompts/csharp.prompt.md renamed to .github/instructions/csharp.instructions.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
---
2+
applyTo: '**/*.cs,**/*.csproj'
3+
---
14
# C# (csharp)
25

36
You are an expert in the latest C# and .NET, you will always follow common idioms, conventions, and best practices when
@@ -20,7 +23,7 @@ be used as an example).
2023
## C# (csharp) Code Conventions and Styles
2124

2225
Before writing any new C#, you will always make sure that your knowledge is up-to-date by referring to the
23-
websites outlined in the [Latest C# (csharp)](#latest-c-csharp) section of this document.
26+
websites outlined in the Latest C# (csharp) section of this document.
2427

2528
Important - You will always prefer the following conventions (unless explicitly told otherwise or the conventions in the
2629
code files differ):
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
applyTo: '**'
3+
---
4+
# Project Instructions
5+
6+
- You will ALWAYS follow the `prompt-instruction-rules`.
7+
- BEFORE/DURING/AFTER ANY edits/responses you will ALWAYS verify that you have read all the content for instruction or prompt files.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
applyTo: '**/*.md'
3+
---
4+
# Markdown Instructions
5+
6+
<!-- <markdown-instructions> -->
7+
- Before any edits you will read required linting rules from ../../.mega-linter.yml.
8+
- You will always edit following the `.mega-linter.yml` rules.
9+
- You will always edit with `markdown-proper-formatting` formatting.
10+
<!-- </markdown-instructions> -->
11+
12+
## Proper Formatting Instructions
13+
14+
<!-- <markdown-proper-formatting> -->
15+
- Headers always have a blank line before and after.
16+
- Titles always have a blank line after #.
17+
- Unordered lists always use `-`.
18+
- Ordered lists always use `1.`.
19+
- Lists always have a blank line before and after.
20+
- Code blocks always use triple backticks with the language specified.
21+
- Tables always have a header row, separator row, and `|` for columns.
22+
- Links always use reference-style for repeated URLs.
23+
- You will only ever allow `details` and `summary` HTML elements.
24+
<!-- </markdown-proper-formatting> -->

.github/prompts/python-script.prompt.md renamed to .github/instructions/python-script.instructions.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
---
2+
applyTo: '**/*.py'
3+
---
14
# Python Script Conventions and Best Practices
25

3-
You are an expert in Python scripting with deep knowledge of best practices and efficient implementation patterns. When writing or evaluating Python scripts for this project, always follow the conventions in this document.
6+
You are an expert in Python scripting with deep knowledge of best practices and efficient implementation patterns.
7+
When writing or evaluating Python scripts for this project, always follow the conventions in this document.
48

59
## Repository Structure
610

7-
This repository contains Python scripts primarily in the `/scripts` directory, serving as utility tools for various infrastructure and deployment tasks. These scripts support the overall project goals described in the [README.md](../../README.md).
11+
This repository contains Python scripts primarily in the `/scripts` directory, serving as utility tools for various infrastructure and deployment tasks.
12+
These scripts support the overall project goals described in the [README.md](../../README.md).
813

914
## Script Types: Utility Scripts vs. Application Scripts
1015

0 commit comments

Comments
 (0)