@pagopa/dx-cli 0.19.2 → 0.20.0
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.
|
@@ -2,14 +2,14 @@ import { getLogger } from "@logtape/logtape";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { formatTerraformCode } from "../../../terraform/fmt.js";
|
|
4
4
|
import { payloadSchema } from "./prompts.js";
|
|
5
|
-
const addModule = (env, templatesPath) => {
|
|
5
|
+
const addModule = (env, templatesPath, init = false) => {
|
|
6
6
|
const cloudAccountsByCsp = Object.groupBy(env.cloudAccounts, (account) => account.csp);
|
|
7
7
|
const includesProdIO = env.cloudAccounts.some((account) => account.displayName === "PROD-IO");
|
|
8
8
|
const cwd = process.cwd();
|
|
9
9
|
return (name, terraformBackendKey) => [
|
|
10
10
|
{
|
|
11
11
|
base: templatesPath,
|
|
12
|
-
data: { cloudAccountsByCsp, includesProdIO },
|
|
12
|
+
data: { cloudAccountsByCsp, includesProdIO, init },
|
|
13
13
|
destination: path.join(cwd, "infra"),
|
|
14
14
|
force: true,
|
|
15
15
|
templateFiles: path.join(templatesPath, name),
|
|
@@ -19,7 +19,7 @@ const addModule = (env, templatesPath) => {
|
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
base: path.join(templatesPath, "shared"),
|
|
22
|
-
data: { cloudAccountsByCsp, terraformBackendKey },
|
|
22
|
+
data: { cloudAccountsByCsp, init, terraformBackendKey },
|
|
23
23
|
destination: path.join(cwd, "infra", name, "{{env.name}}"),
|
|
24
24
|
force: true,
|
|
25
25
|
templateFiles: path.join(templatesPath, "shared"),
|
|
@@ -34,7 +34,7 @@ export default function getActions(templatesPath) {
|
|
|
34
34
|
const logger = getLogger(["gen", "env"]);
|
|
35
35
|
logger.debug("payload {payload}", { payload });
|
|
36
36
|
const { env, github, init } = payloadSchema.parse(payload);
|
|
37
|
-
const addEnvironmentModule = addModule(env, templatesPath);
|
|
37
|
+
const addEnvironmentModule = addModule(env, templatesPath, !!init);
|
|
38
38
|
const actions = [
|
|
39
39
|
{
|
|
40
40
|
type: "getTerraformBackend",
|
package/package.json
CHANGED
|
@@ -120,6 +120,32 @@ module "azure-{{displayName}}_bootstrap" {
|
|
|
120
120
|
|
|
121
121
|
tags = local.bootstrapper_tags
|
|
122
122
|
}
|
|
123
|
+
|
|
124
|
+
{{#if @root.init}}
|
|
125
|
+
resource "azurerm_role_assignment" "infra_cd_user_access_admin_common_rg_{{displayName}}" {
|
|
126
|
+
provider = azurerm.{{displayName}}
|
|
127
|
+
|
|
128
|
+
scope = module.azure-{{displayName}}_core_values.common_resource_group_id
|
|
129
|
+
role_definition_name = "User Access Administrator"
|
|
130
|
+
principal_id = module.azure-{{displayName}}_bootstrap.identities.infra.cd.principal_id
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
resource "azurerm_role_assignment" "infra_cd_kv_secrets_officer_common_{{displayName}}" {
|
|
134
|
+
provider = azurerm.{{displayName}}
|
|
135
|
+
|
|
136
|
+
scope = module.azure-{{displayName}}_core_values.common_key_vault.id
|
|
137
|
+
role_definition_name = "Key Vault Secrets Officer"
|
|
138
|
+
principal_id = module.azure-{{displayName}}_bootstrap.identities.infra.cd.principal_id
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
resource "azurerm_role_assignment" "infra_ci_kv_secrets_user_common_{{displayName}}" {
|
|
142
|
+
provider = azurerm.{{displayName}}
|
|
143
|
+
|
|
144
|
+
scope = module.azure-{{displayName}}_core_values.common_key_vault.id
|
|
145
|
+
role_definition_name = "Key Vault Secrets User"
|
|
146
|
+
principal_id = module.azure-{{displayName}}_bootstrap.identities.infra.ci.principal_id
|
|
147
|
+
}
|
|
148
|
+
{{/if}}
|
|
123
149
|
{{/if}}
|
|
124
150
|
{{/each}}
|
|
125
151
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
{{#each this}}
|
|
3
3
|
module "azure-{{displayName}}_core" {
|
|
4
4
|
source = "pagopa-dx/azure-core-infra/azurerm"
|
|
5
|
-
version = "~>
|
|
5
|
+
version = "~> 3.0"
|
|
6
6
|
|
|
7
7
|
providers = {
|
|
8
8
|
azurerm = azurerm.{{displayName}}
|
|
@@ -12,6 +12,8 @@ module "azure-{{displayName}}_core" {
|
|
|
12
12
|
app_name = "core"
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
+
vpn_enabled = true
|
|
16
|
+
|
|
15
17
|
tags = merge(local.tags, {
|
|
16
18
|
Source = "https://github.com/{{@root.github.owner}}/{{@root.github.repo}}/blob/main/infra/core/{{@root.env.name}}"
|
|
17
19
|
})
|