@pagopa/dx-cli 0.25.0 → 0.25.1
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.
- package/dist/adapters/azure/cloud-account-service.js +138 -92
- package/dist/adapters/azure/locations.d.ts +5 -1
- package/dist/adapters/azure/locations.js +1 -1
- package/dist/adapters/commander/commands/init.js +64 -15
- package/dist/adapters/github/github-repo.js +20 -2
- package/dist/domain/environment.d.ts +6 -1
- package/dist/domain/environment.js +1 -1
- package/package.json +23 -23
- package/templates/environment/workflow/_release-terraform-apply-bootstrapper-{{env.name}}.yaml.hbs +145 -2
package/templates/environment/workflow/_release-terraform-apply-bootstrapper-{{env.name}}.yaml.hbs
CHANGED
|
@@ -1,18 +1,161 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Bootstrapper Infrastructure - {{@root.env.name}}
|
|
2
2
|
on:
|
|
3
3
|
workflow_dispatch:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
6
|
- main
|
|
7
7
|
paths:
|
|
8
|
-
- "infra/bootstrapper/**"
|
|
8
|
+
- "infra/bootstrapper/{{@root.env.name}}/**"
|
|
9
|
+
- ".github/workflows/_release-terraform-apply-bootstrapper-{{@root.env.name}}.yaml"
|
|
10
|
+
pull_request:
|
|
11
|
+
types:
|
|
12
|
+
- opened
|
|
13
|
+
- edited
|
|
14
|
+
- synchronize
|
|
15
|
+
- reopened
|
|
16
|
+
- ready_for_review
|
|
17
|
+
paths:
|
|
18
|
+
- "infra/bootstrapper/{{@root.env.name}}/**"
|
|
19
|
+
- ".github/workflows/_release-terraform-apply-bootstrapper-{{@root.env.name}}.yaml"
|
|
9
20
|
|
|
10
21
|
permissions:
|
|
11
22
|
contents: read
|
|
12
23
|
id-token: write
|
|
24
|
+
pull-requests: write
|
|
13
25
|
|
|
14
26
|
jobs:
|
|
27
|
+
plan:
|
|
28
|
+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
|
|
29
|
+
name: Terraform Plan ({{@root.env.name}})
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
environment: bootstrapper-{{@root.env.name}}-ci
|
|
32
|
+
permissions:
|
|
33
|
+
id-token: write
|
|
34
|
+
contents: read
|
|
35
|
+
pull-requests: write
|
|
36
|
+
env:
|
|
37
|
+
ARM_CLIENT_ID: $\{{ secrets.ARM_CLIENT_ID }}
|
|
38
|
+
ARM_TENANT_ID: $\{{ secrets.ARM_TENANT_ID }}
|
|
39
|
+
ARM_SUBSCRIPTION_ID: $\{{ secrets.ARM_SUBSCRIPTION_ID }}
|
|
40
|
+
ARM_USE_OIDC: true
|
|
41
|
+
ARM_USE_AZUREAD: true
|
|
42
|
+
ARM_STORAGE_USE_AZUREAD: true
|
|
43
|
+
ROLE_ARN: $\{{ secrets.ROLE_ARN }}
|
|
44
|
+
AWS_REGION: $\{{ secrets.AWS_REGION }}
|
|
45
|
+
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
|
|
46
|
+
TF_IN_AUTOMATION: true
|
|
47
|
+
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
50
|
+
name: Checkout
|
|
51
|
+
|
|
52
|
+
- name: Get terraform version from .terraform-version file
|
|
53
|
+
id: get-version
|
|
54
|
+
uses: pagopa/dx/.github/actions/get-terraform-version@main
|
|
55
|
+
|
|
56
|
+
- name: Setup Telemetry Session
|
|
57
|
+
uses: pagopa/dx/actions/setup-telemetry@main
|
|
58
|
+
|
|
59
|
+
- name: Cloud Login
|
|
60
|
+
uses: pagopa/dx/actions/csp-login@main
|
|
61
|
+
|
|
62
|
+
- name: Terraform Setup
|
|
63
|
+
uses: pagopa/dx/.github/actions/terraform-setup@main
|
|
64
|
+
with:
|
|
65
|
+
terraform_version: $\{{ steps.get-version.outputs.terraform_version }}
|
|
66
|
+
|
|
67
|
+
- name: Terraform Init
|
|
68
|
+
working-directory: infra/bootstrapper/{{@root.env.name}}
|
|
69
|
+
run: |
|
|
70
|
+
terraform init -input=false
|
|
71
|
+
|
|
72
|
+
- name: Start Terraform Plan telemetry span
|
|
73
|
+
uses: pagopa/dx/actions/log-telemetry-event@main
|
|
74
|
+
with:
|
|
75
|
+
name: terraform-plan
|
|
76
|
+
span_phase: start
|
|
77
|
+
|
|
78
|
+
- name: Terraform Plan
|
|
79
|
+
id: plan
|
|
80
|
+
uses: pagopa/dx/actions/sanitize-terraform-plan@main
|
|
81
|
+
with:
|
|
82
|
+
base-path: infra/bootstrapper/{{@root.env.name}}
|
|
83
|
+
sensitive-keys: hidden-link,APPINSIGHTS_INSTRUMENTATIONKEY
|
|
84
|
+
|
|
85
|
+
- name: End Terraform Plan telemetry span
|
|
86
|
+
if: always()
|
|
87
|
+
uses: pagopa/dx/actions/log-telemetry-event@main
|
|
88
|
+
with:
|
|
89
|
+
name: terraform-plan
|
|
90
|
+
span_phase: end
|
|
91
|
+
|
|
92
|
+
- name: Check Plan length
|
|
93
|
+
id: check-length
|
|
94
|
+
working-directory: infra/bootstrapper/{{@root.env.name}}
|
|
95
|
+
run: |
|
|
96
|
+
# If the sanitized plan is too long use the summary line, otherwise use the full sanitized plan
|
|
97
|
+
if [ "$(wc -c < "${PLAN_FILE_PATH#"$WORKING_DIRECTORY/"}")" -gt 60000 ]; then
|
|
98
|
+
echo "${SUMMARY_LINE}" > plan_output.txt
|
|
99
|
+
echo "COMPLETE_PLAN=false" >> "$GITHUB_OUTPUT"
|
|
100
|
+
else
|
|
101
|
+
cat "${PLAN_FILE_PATH#"$WORKING_DIRECTORY/"}" > plan_output.txt
|
|
102
|
+
echo "COMPLETE_PLAN=true" >> "$GITHUB_OUTPUT"
|
|
103
|
+
fi
|
|
104
|
+
env:
|
|
105
|
+
SUMMARY_LINE: $\{{ steps.plan.outputs.summary_line }}
|
|
106
|
+
PLAN_FILE_PATH: $\{{ steps.plan.outputs.filtered_plan_path }}
|
|
107
|
+
WORKING_DIRECTORY: infra/bootstrapper/{{@root.env.name}}
|
|
108
|
+
|
|
109
|
+
- name: Set Plan Output
|
|
110
|
+
id: set-plan-output
|
|
111
|
+
if: always()
|
|
112
|
+
working-directory: infra/bootstrapper/{{@root.env.name}}
|
|
113
|
+
run: |
|
|
114
|
+
echo "### 📖 Terraform Plan ($OUTPUT_DIR) - $PLAN_OUTCOME" > message_body.txt
|
|
115
|
+
echo "<details>" >> message_body.txt
|
|
116
|
+
echo "<summary>Show Plan</summary>" >> message_body.txt
|
|
117
|
+
echo "" >> message_body.txt
|
|
118
|
+
|
|
119
|
+
if [ "$PLAN_OUTCOME" != 'success' ]; then
|
|
120
|
+
echo "Terraform plan execution failed. Check the [workflow logs]($WORKFLOW_URL) for full details." >> message_body.txt
|
|
121
|
+
else
|
|
122
|
+
echo "\`\`\`hcl" >> message_body.txt
|
|
123
|
+
cat plan_output.txt >> message_body.txt
|
|
124
|
+
echo "\`\`\`" >> message_body.txt
|
|
125
|
+
|
|
126
|
+
if [ "$COMPLETE_PLAN" = 'false' ]; then
|
|
127
|
+
echo "Full plan output was too long and was omitted. Check the [workflow logs]($WORKFLOW_URL) for full details." >> message_body.txt
|
|
128
|
+
fi
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
echo "" >> message_body.txt
|
|
132
|
+
echo "</details>" >> message_body.txt
|
|
133
|
+
env:
|
|
134
|
+
WORKFLOW_URL: $\{{ github.server_url }}/$\{{ github.repository }}/actions/runs/$\{{ github.run_id }}
|
|
135
|
+
OUTPUT_DIR: infra/bootstrapper/{{@root.env.name}}
|
|
136
|
+
PLAN_OUTCOME: $\{{ steps.plan.outcome }}
|
|
137
|
+
COMPLETE_PLAN: $\{{ steps.check-length.outputs.COMPLETE_PLAN }}
|
|
138
|
+
|
|
139
|
+
- name: Post Plan on PR
|
|
140
|
+
id: comment
|
|
141
|
+
if: always()
|
|
142
|
+
uses: pagopa/dx/actions/pr-comment@main
|
|
143
|
+
with:
|
|
144
|
+
comment-body-file: infra/bootstrapper/{{@root.env.name}}/message_body.txt
|
|
145
|
+
search-pattern: "Terraform Plan (infra/bootstrapper/{{@root.env.name}})"
|
|
146
|
+
|
|
147
|
+
- name: Set Telemetry Failure Result
|
|
148
|
+
if: failure()
|
|
149
|
+
run: |
|
|
150
|
+
echo "PIPELINE_RESULT=failure" >> "$GITHUB_ENV"
|
|
151
|
+
|
|
152
|
+
- name: Check Terraform Plan Result
|
|
153
|
+
if: always() && steps.plan.outcome != 'success'
|
|
154
|
+
run: |
|
|
155
|
+
exit 1
|
|
156
|
+
|
|
15
157
|
release:
|
|
158
|
+
if: github.event_name != 'pull_request'
|
|
16
159
|
uses: pagopa/dx/.github/workflows/release-terraform-bootstrapper-v1.yaml@main
|
|
17
160
|
name: Release Bootstrapper ({{@root.env.name}})
|
|
18
161
|
secrets: inherit
|