aws-data-landing-zone 0.0.36 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.jsii +141 -161
  2. package/API.md +62 -642
  3. package/docs/.env.development +3 -0
  4. package/docs/astro.config.ts +92 -74
  5. package/docs/cloudflare_build.sh +9 -0
  6. package/docs/package-lock.json +17 -0
  7. package/docs/package.json +5 -1
  8. package/docs/src/components/Footer.astro +2 -2
  9. package/docs/src/content/docs/components/account-management/introduction.mdx +0 -80
  10. package/docs/src/content/docs/components/build-system/ci-integration.mdx +336 -0
  11. package/docs/src/content/docs/components/build-system/deployment-order.mdx +608 -0
  12. package/docs/src/content/docs/components/build-system/overview.mdx +37 -0
  13. package/docs/src/content/docs/components/identity/introduction.mdx +0 -80
  14. package/docs/src/content/docs/reference/api.md +21123 -0
  15. package/docs/src/styles/custom.css +3 -5
  16. package/lib/constructs/account-chatbots/index.js +1 -1
  17. package/lib/constructs/dlz-budget/index.js +1 -1
  18. package/lib/constructs/dlz-control-tower-control/control-tower-control.js +1 -1
  19. package/lib/constructs/dlz-lake-formation/dlz-lake-formation.js +1 -1
  20. package/lib/constructs/dlz-ssm-reader/dlz-ssm-reader-stack-cache.js +1 -1
  21. package/lib/constructs/dlz-ssm-reader/dlz-ssm-reader.js +1 -1
  22. package/lib/constructs/dlz-stack/index.d.ts +13 -0
  23. package/lib/constructs/dlz-stack/index.js +17 -2
  24. package/lib/constructs/dlz-vpc/dlz-account-networks.js +1 -1
  25. package/lib/constructs/dlz-vpc/dlz-vpc.js +1 -1
  26. package/lib/constructs/dlz-vpc/network-address.js +1 -1
  27. package/lib/constructs/iam-identity-center/iam-identity-center-group.js +1 -1
  28. package/lib/constructs/iam-identity-center/iam-identity-center.js +1 -1
  29. package/lib/constructs/iam-identity-center/identity-store-user.js +1 -1
  30. package/lib/constructs/organization-policies/service-control-policy.js +1 -1
  31. package/lib/constructs/organization-policies/tag-policy.js +1 -1
  32. package/lib/data-landing-zone-client.js +1 -1
  33. package/lib/data-landing-zone-types.d.ts +18 -4
  34. package/lib/data-landing-zone-types.js +1 -1
  35. package/lib/data-landing-zone.js +61 -63
  36. package/lib/defaults.js +1 -1
  37. package/lib/lib/report/index.js +1 -1
  38. package/lib/stacks/organization/management-stack.js +1 -1
  39. package/lib/stacks/organization/security/audit/global-stack.js +1 -1
  40. package/lib/stacks/organization/security/audit/regional-stack.js +1 -1
  41. package/lib/stacks/organization/security/log/global-stack.js +1 -1
  42. package/lib/stacks/organization/security/log/regional-stack.js +1 -1
  43. package/lib/stacks/organization/workloads/base/global-stack.js +1 -1
  44. package/lib/stacks/organization/workloads/base/regional-stack.js +1 -1
  45. package/lib/stacks/organization/workloads/data-services-phase-1-stack/global-stack.js +1 -1
  46. package/lib/stacks/organization/workloads/data-services-phase-1-stack/regional-stack.js +1 -1
  47. package/lib/stacks/organization/workloads/network-connections-phase-1-stack/global-stack.js +1 -1
  48. package/lib/stacks/organization/workloads/network-connections-phase-2-stack/global-stack.js +1 -1
  49. package/lib/stacks/organization/workloads/network-connections-phase-2-stack/regional-stack.js +1 -1
  50. package/lib/stacks/organization/workloads/network-connections-phase-3-stack/global-stack.js +1 -1
  51. package/lib/stacks/organization/workloads/network-connections-phase-3-stack/regional-stack.js +1 -1
  52. package/no-op-force-build.txt +1 -0
  53. package/package.json +1 -1
  54. package/post-docgen.sh +10 -0
@@ -0,0 +1,336 @@
1
+ ---
2
+ title: CI Integration
3
+ description: Build System - CI Integration
4
+ ---
5
+ import DualCode from '../../../../components/DualCode.astro';
6
+
7
+ The Data Landing Zone (DLZ) construct offers built-in support to streamline authentication between AWS and CI/CD
8
+ systems, enhancing security and simplifying setup processes.
9
+
10
+ Relevant API References:
11
+ - [DeploymentPlatform](/reference/api#deploymentplatform)
12
+
13
+ ## GitHub Actions
14
+
15
+ DLZ facilitates seamless integration with GitHub Actions using OpenID Connect (OIDC). OIDC is recommended over
16
+ long-lived IAM credentials due to its enhanced security and flexibility. For detailed information, refer to the
17
+ official documentation from [Github](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services)
18
+ or
19
+ [AWS](https://aws.amazon.com/blogs/security/use-iam-roles-to-connect-github-actions-to-actions-in-aws/)
20
+
21
+ We first need to configure the AWS side and then pass the generated IAM Role ARN to the GitHub Actions workflow.
22
+
23
+ ### 1. Config AWS
24
+
25
+ :::note
26
+ The OIDC role has to be created before it can be used by GitHub Actions. This creates a "chicken and egg" problem and
27
+ requires manual deployment of the `management` stack. This only has to be done manually once as setup for the OIDC
28
+ integration, more details at the end of this section.
29
+ :::
30
+
31
+
32
+ The following section demonstrates how to configure OIDC integration for a sample repository.
33
+ This example uses the [DataChefHQ/data-landing-zone-example-typescript](https://github.com/DataChefHQ/data-landing-zone-example-typescript)
34
+ repository. Ensure you replace the placeholders with values specific to your setup.
35
+
36
+ <DualCode>
37
+ <Fragment slot="ts">
38
+ ```ts
39
+ const dlz = new DataLandingZone(app, {
40
+ ...
41
+ deploymentPlatform: {
42
+ gitHub: {
43
+ references: [
44
+ { owner: 'DataChefHQ', repo: 'data-landing-zone-example-typescript ' },
45
+ // { owner: "DataChefHQ", repo: 'recipes_data-landing-zone_data-landing-zone-sandbox', filter: "refs/heads/main"}
46
+ ],
47
+ },
48
+ },
49
+ });
50
+ ```
51
+ </Fragment>
52
+ <Fragment slot="python">
53
+ ```python
54
+ dlz.DataLandingZone(app,
55
+ ...
56
+ deployment_platform=dlz.DeploymentPlatform(
57
+ git_hub=dlz.GitHub(
58
+ references=[
59
+ dlz.GitHubReference(owner='DataChefHQ', repo='data-landing-zone-example-typescript'),
60
+ # dlz.GitHubReference(owner='DataChefHQ', repo='recipes_data-landing-zone_data-landing-zone-sandbox', filter='main')
61
+ ]
62
+ )
63
+ )
64
+ )
65
+ ```
66
+ </Fragment>
67
+ </DualCode>
68
+
69
+ The example above does not specify the `filter` property, which means all environments, tags, branches and PRs can
70
+ assume the generated IAM Role to authenticate with AWS. For a complete list of filters see the
71
+ [Github documentation](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect#understanding-the-oidc-token)
72
+
73
+ Some common Examples:
74
+ - `environment:ENVIRONMENT-NAME` - Specific environment
75
+ - `ref:refs/heads/BRANCH-NAME` - Specific branch
76
+ - `ref:refs/tags/TAG-NAME` - Specific tag
77
+ - `pull_request` - Only PRs
78
+
79
+ A `*` can be used for most parts of the `ENVIRONMENT-NAME`, `BRANCH-NAME`, `TAG-NAME`
80
+
81
+ #### Manual setup deployment
82
+
83
+ The OIDC role created by the configuration above has to happen before it can be used by GitHub Actions. This creates
84
+ a "chicken and egg" problem and requires manual deployment of the `management` stack. This only has to be done
85
+ manually once as setup for the OIDC integration.
86
+
87
+ ```bash
88
+ cdk deploy "root--global_management_*"
89
+ ```
90
+
91
+ After deployment, the OIDC role ARN can be found in the `dlz-global` stack outputs with the name
92
+ `dlz-global-git-hub-deploy-role`. It will be in this format:
93
+
94
+ ```
95
+ arn:aws:iam::YOUR_MANAGEMENT_ACCOUNT_ID:role/dlz-global-git-hub-deploy-role
96
+ ```
97
+
98
+ ----
99
+
100
+ Relevant API References:
101
+ - [DeploymentPlatformGitHub](/reference/api#deploymentplatformgithub--1)
102
+ - [GitHubReference](/reference/api#githubreference)
103
+
104
+ ### 2. Use within GitHub workflows
105
+
106
+ The GitHub workflow for the given repository can now be updated to use the OIDC role ARN.
107
+ It is important to set the `permissions` so that `aws-actions/configure-aws-credentials@v4` works correctly.
108
+
109
+ This workflow can be used to do a CDK diff when a PR is opened or synchronized. It can also be triggered manually.
110
+ ```yaml title=".github/workflows/diff.yml" {12-15, 26-30}
111
+ name: Diff
112
+ on:
113
+ pull_request:
114
+ types: [opened, synchronize]
115
+ workflow_dispatch: {}
116
+ env:
117
+ FORCE_COLOR: 1
118
+ jobs:
119
+ deploy:
120
+ name: CDK Diff and Deploy
121
+ runs-on: ubuntu-latest
122
+ permissions:
123
+ actions: write
124
+ contents: read
125
+ id-token: write
126
+ steps:
127
+ - name: Checkout repo
128
+ uses: actions/checkout@v4
129
+ - name: Set up node
130
+ uses: actions/setup-node@v3
131
+ with:
132
+ node-version: 20
133
+ cache: npm
134
+ - name: Install dependencies
135
+ run: npm install ci
136
+ - name: Configure AWS credentials
137
+ uses: aws-actions/configure-aws-credentials@v4
138
+ with:
139
+ role-to-assume: arn:aws:iam::YOUR_MANAGEMENT_ACCOUNT_ID:role/dlz-global-git-hub-deploy-role
140
+ aws-region: YOUR_MANAGEMENT_ACCOUNT_GLOBAL_REGION
141
+ - name: CDK diff
142
+ run: "cdk diff \"**\""
143
+ ```
144
+
145
+ This workflow can be used to do a CDK deploy when a PR is merged. It can also be triggered manually.
146
+ ```yaml title=".github/workflows/deploy.yml"
147
+ name: Deploy
148
+ on:
149
+ push:
150
+ branches:
151
+ - main
152
+ workflow_dispatch: {}
153
+ env:
154
+ FORCE_COLOR: 1
155
+ jobs:
156
+ deploy:
157
+ name: CDK Diff and Deploy
158
+ runs-on: ubuntu-latest
159
+ permissions:
160
+ actions: write
161
+ contents: read
162
+ id-token: write
163
+ steps:
164
+ - name: Checkout repo
165
+ uses: actions/checkout@v4
166
+ - name: Set up node
167
+ uses: actions/setup-node@v3
168
+ with:
169
+ node-version: 20
170
+ cache: npm
171
+ - name: Install dependencies
172
+ run: npm install ci
173
+ - name: Configure AWS credentials
174
+ uses: aws-actions/configure-aws-credentials@v4
175
+ with:
176
+ role-to-assume: arn:aws:iam::YOUR_MANAGEMENT_ACCOUNT_ID:role/dlz-global-git-hub-deploy-role
177
+ aws-region: YOUR_MANAGEMENT_ACCOUNT_GLOBAL_REGION
178
+ - name: CDK diff
179
+ run: npm run diff
180
+ - name: CDK deploy
181
+ run: "cdk deploy \"**\" --require-approval never --progress events --concurrency 10"
182
+ ```
183
+
184
+ It is possible to split the deployment of the `development` and `production` workload accounts and place an approval step
185
+ in the middle. This requires knowledge of the correct CDK commands to use. The example below demonstrates this.
186
+
187
+
188
+ <details>
189
+ <summary>
190
+ Click to show the **Advance Deploy Workflow**
191
+ </summary>
192
+
193
+ Ensure that the the `production` GitHub environment exists and is configured to require manual approval. See the
194
+ [GitHub documentation](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-deployments/managing-environments-for-deployment#deployment-protection-rules)
195
+ for more information.
196
+
197
+ This workflow first builds the CDK cloud assembly and caches the assets. It then deploys the Management and Security
198
+ Phases. Then it deploys the all the `type: DlzAccountType.DEVELOP` workload stacks. The last job deploys the
199
+ `type: DlzAccountType.PRODUCTION` workload stacks. But this job will not start as it has the `environment: production`
200
+ property set and will only start after manual Approval has been given on GitHub.
201
+
202
+ ```yaml title=".github/workflows/deploy.yml"
203
+ name: Deploy
204
+ on:
205
+ push:
206
+ branches:
207
+ - main
208
+ workflow_dispatch: {} # While testing only
209
+ env:
210
+ FORCE_COLOR: 1
211
+ jobs:
212
+ synth:
213
+ name: Build and Synth
214
+ runs-on: ubuntu-latest
215
+ permissions:
216
+ actions: write
217
+ contents: read
218
+ id-token: write
219
+ steps:
220
+ - name: Checkout repo
221
+ uses: actions/checkout@v4
222
+ - name: Set up node
223
+ uses: actions/setup-node@v3
224
+ with:
225
+ node-version: 20
226
+ cache: npm
227
+ - name: Install dependencies
228
+ run: npm install ci
229
+ - name: Configure AWS credentials
230
+ uses: aws-actions/configure-aws-credentials@v4
231
+ with:
232
+ role-to-assume: arn:aws:iam::YOUR_MANAGEMENT_ACCOUNT_ID:role/dlz-global-git-hub-deploy-role
233
+ aws-region: YOUR_MANAGEMENT_ACCOUNT_GLOBAL_REGION
234
+ - name: CDK Synth
235
+ run: npm run cdk -- synth --output ./cloud_assembly_output
236
+ - name: Cache CDK Assets
237
+ uses: actions/cache/save@v4
238
+ with:
239
+ path: ./
240
+ key: "cdk-assets-${{ github.sha }}"
241
+
242
+ root:
243
+ needs:
244
+ - synth
245
+ uses: ./.github/workflows/cdk-diff-deploy-cloud-assembly.yml
246
+ permissions:
247
+ actions: write
248
+ contents: read
249
+ id-token: write
250
+ secrets: inherit
251
+ with:
252
+ name: Root Deploy
253
+ stack_selection: "root--*"
254
+
255
+ security:
256
+ needs:
257
+ - root
258
+ uses: ./.github/workflows/cdk-diff-deploy-cloud-assembly.yml
259
+ permissions:
260
+ actions: write
261
+ contents: read
262
+ id-token: write
263
+ secrets: inherit
264
+ with:
265
+ name: Security Deploy
266
+ stack_selection: "security--*"
267
+
268
+ workloads-development:
269
+ needs:
270
+ - security
271
+ uses: ./.github/workflows/cdk-diff-deploy-cloud-assembly.yml
272
+ permissions:
273
+ actions: write
274
+ contents: read
275
+ id-token: write
276
+ secrets: inherit
277
+ with:
278
+ name: Workloads Development Deploy
279
+ stack_selection: "*_development--*_*"
280
+
281
+ workloads-production:
282
+ environment: production
283
+ needs:
284
+ - workloads-development
285
+ needs:
286
+ - security
287
+ uses: ./.github/workflows/cdk-diff-deploy-cloud-assembly.yml
288
+ permissions:
289
+ actions: write
290
+ contents: read
291
+ id-token: write
292
+ secrets: inherit
293
+ with:
294
+ name: Workloads Production Deploy
295
+ stack_selection: "*_production--*_*"
296
+ ```
297
+
298
+ Create following composable action file in the `.github/workflows` directory as it is used in the above workflow to
299
+ prevent code duplication.
300
+
301
+ ```yaml title=".github/workflows/cdk-diff-deploy-cloud-assembly.yml"
302
+ name: Diff CDK Application
303
+ on:
304
+ workflow_call:
305
+ inputs:
306
+ name:
307
+ description: The name of the job
308
+ required: true
309
+ type: string
310
+ stack_selection:
311
+ description: The CDK stack selector
312
+ required: true
313
+ type: string
314
+ env:
315
+ FORCE_COLOR: 1
316
+ jobs:
317
+ job:
318
+ name: ${{ inputs.name }}
319
+ runs-on: ubuntu-latest
320
+ steps:
321
+ - name: Fetch CDK Assets
322
+ uses: actions/cache/restore@v4
323
+ with:
324
+ path: ./
325
+ key: "cdk-assets-${{ github.sha }}"
326
+ - name: Configure AWS credentials
327
+ uses: aws-actions/configure-aws-credentials@v4
328
+ with:
329
+ role-to-assume: arn:aws:iam::YOUR_MANAGEMENT_ACCOUNT_ID:role/dlz-global-git-hub-deploy-role
330
+ aws-region: YOUR_MANAGEMENT_ACCOUNT_GLOBAL_REGION
331
+ - name: CDK diff
332
+ run: npm run cdk -- diff '${{ inputs.stack_selection }}' --exclusively --app ./cloud_assembly_output
333
+ - name: CDK deploy
334
+ run: npm run cdk -- deploy '${{ inputs.stack_selection }}' --require-approval never --concurrency 10 --exclusively --app ./cloud_assembly_output
335
+ ```
336
+ </details>