dcl-ops-lib 9.6.0 → 9.7.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.
- package/createFargateTask.d.ts +17 -2
- package/createFargateTask.js +27 -15
- package/package.json +1 -1
package/createFargateTask.d.ts
CHANGED
|
@@ -12,11 +12,11 @@ export type ALBMapping = {
|
|
|
12
12
|
healthCheck?: Partial<aws.types.input.alb.TargetGroupHealthCheck>;
|
|
13
13
|
extraExposedServiceOptions?: ExtraExposedServiceOptions;
|
|
14
14
|
};
|
|
15
|
-
export declare function getFargateExecutionRole(name: string, policyArnNamedMap: Record<string, pulumi.Input<string> | aws.iam.Policy
|
|
15
|
+
export declare function getFargateExecutionRole(name: string, policyArnNamedMap: Record<string, pulumi.Input<string> | aws.iam.Policy>, existingRole?: aws.iam.Role): {
|
|
16
16
|
role: import("@pulumi/aws/iam/role").Role;
|
|
17
17
|
policies: import("@pulumi/aws/iam/rolePolicyAttachment").RolePolicyAttachment[];
|
|
18
18
|
};
|
|
19
|
-
export declare function getFargateTaskRole(name: string, policyArnNamedMap: Record<string, pulumi.Input<string> | aws.iam.Policy
|
|
19
|
+
export declare function getFargateTaskRole(name: string, policyArnNamedMap: Record<string, pulumi.Input<string> | aws.iam.Policy>, existingRole?: aws.iam.Role): {
|
|
20
20
|
role: import("@pulumi/aws/iam/role").Role;
|
|
21
21
|
policies: import("@pulumi/aws/iam/rolePolicyAttachment").RolePolicyAttachment[];
|
|
22
22
|
};
|
|
@@ -43,6 +43,21 @@ export type FargateTaskOptions = {
|
|
|
43
43
|
nlbMappings?: NLBMapping[];
|
|
44
44
|
executionRolePolicies?: Record<string, pulumi.Input<string> | aws.iam.Policy>;
|
|
45
45
|
taskRolePolicies?: Record<string, pulumi.Input<string> | aws.iam.Policy>;
|
|
46
|
+
/**
|
|
47
|
+
* Optional pre-built IAM role to use as the Fargate task role. When provided,
|
|
48
|
+
* the role is used as-is and `taskRolePolicies` are attached to it. When omitted
|
|
49
|
+
* (default), a new role is created internally — current behavior, fully backward
|
|
50
|
+
* compatible. Use this when callers need the task role ARN to exist before the
|
|
51
|
+
* Fargate task (e.g., to scope a KMS key policy to that exact ARN).
|
|
52
|
+
*/
|
|
53
|
+
taskRole?: aws.iam.Role;
|
|
54
|
+
/**
|
|
55
|
+
* Optional pre-built IAM role to use as the Fargate execution role. When provided,
|
|
56
|
+
* the role is used as-is and `executionRolePolicies` are attached to it. When
|
|
57
|
+
* omitted (default), a new role is created internally — current behavior, fully
|
|
58
|
+
* backward compatible. Symmetric to `taskRole`; same use case.
|
|
59
|
+
*/
|
|
60
|
+
executionRole?: aws.iam.Role;
|
|
46
61
|
secrets?: aws.ecs.Secret[];
|
|
47
62
|
ignoreServiceDiscovery?: boolean;
|
|
48
63
|
team: Team;
|
package/createFargateTask.js
CHANGED
|
@@ -49,12 +49,18 @@ async function getClusterInstance(cluster) {
|
|
|
49
49
|
return cluster.arn;
|
|
50
50
|
}
|
|
51
51
|
exports.getClusterInstance = getClusterInstance;
|
|
52
|
-
function getFargateExecutionRole(name, policyArnNamedMap) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
function getFargateExecutionRole(name, policyArnNamedMap, existingRole) {
|
|
53
|
+
let role;
|
|
54
|
+
if (existingRole) {
|
|
55
|
+
role = existingRole;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const assumeRolePolicy = aws.iam.assumeRolePolicyForPrincipal({
|
|
59
|
+
Service: "ecs-tasks.amazonaws.com",
|
|
60
|
+
});
|
|
61
|
+
const dependsOn = Object.values(policyArnNamedMap).filter(($) => $ instanceof pulumi.Resource);
|
|
62
|
+
role = new aws.iam.Role(name, { assumeRolePolicy }, { dependsOn });
|
|
63
|
+
}
|
|
58
64
|
const policies = [];
|
|
59
65
|
// Default execution policy
|
|
60
66
|
policies.push(new aws.iam.RolePolicyAttachment(`${name}-default-execution-policy`, {
|
|
@@ -72,12 +78,18 @@ function getFargateExecutionRole(name, policyArnNamedMap) {
|
|
|
72
78
|
return { role, policies };
|
|
73
79
|
}
|
|
74
80
|
exports.getFargateExecutionRole = getFargateExecutionRole;
|
|
75
|
-
function getFargateTaskRole(name, policyArnNamedMap) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
function getFargateTaskRole(name, policyArnNamedMap, existingRole) {
|
|
82
|
+
let role;
|
|
83
|
+
if (existingRole) {
|
|
84
|
+
role = existingRole;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const assumeRolePolicy = aws.iam.assumeRolePolicyForPrincipal({
|
|
88
|
+
Service: "ecs-tasks.amazonaws.com",
|
|
89
|
+
});
|
|
90
|
+
const dependsOn = Object.values(policyArnNamedMap).filter(($) => $ instanceof pulumi.Resource);
|
|
91
|
+
role = new aws.iam.Role(name, { assumeRolePolicy }, { dependsOn });
|
|
92
|
+
}
|
|
81
93
|
const policies = [];
|
|
82
94
|
Object.entries(policyArnNamedMap).forEach(([key, policyArn]) => {
|
|
83
95
|
if (policyArn instanceof aws.iam.Policy) {
|
|
@@ -104,7 +116,7 @@ exports.getFargateTaskRole = getFargateTaskRole;
|
|
|
104
116
|
* @param options.appAutoscaling Configuration for autoscaling
|
|
105
117
|
*/
|
|
106
118
|
async function createFargateTask(serviceName, dockerImage, dockerListeningPort, environment, hostname, options) {
|
|
107
|
-
let { healthCheck, healthCheckContainer, essential, dontExpose, securityGroups, cluster, memoryReservation, command, version, ephemeralStorageInGB, desiredCount, cpuReservation, extraPortMappings, extraALBMappings, nlbMappings, executionRolePolicies, taskRolePolicies, ignoreServiceDiscovery, secrets, metrics, forceNewDeployment, dontAssignPublicIp, dependsOn, volumes, deregistrationDelay, mountPoints, repositoryCredentials, team, appAutoscaling, enableExecuteCommand, } = options;
|
|
119
|
+
let { healthCheck, healthCheckContainer, essential, dontExpose, securityGroups, cluster, memoryReservation, command, version, ephemeralStorageInGB, desiredCount, cpuReservation, extraPortMappings, extraALBMappings, nlbMappings, executionRolePolicies, taskRolePolicies, taskRole: existingTaskRole, executionRole: existingExecutionRole, ignoreServiceDiscovery, secrets, metrics, forceNewDeployment, dontAssignPublicIp, dependsOn, volumes, deregistrationDelay, mountPoints, repositoryCredentials, team, appAutoscaling, enableExecuteCommand, } = options;
|
|
108
120
|
if (undefined === essential) {
|
|
109
121
|
essential = true;
|
|
110
122
|
}
|
|
@@ -141,9 +153,9 @@ async function createFargateTask(serviceName, dockerImage, dockerListeningPort,
|
|
|
141
153
|
if (undefined === secrets) {
|
|
142
154
|
secrets = [];
|
|
143
155
|
}
|
|
144
|
-
const { role: executionRole, policies: executionPolicies } = getFargateExecutionRole(`${serviceName}-${version}-execution`, executionRolePolicies || {});
|
|
156
|
+
const { role: executionRole, policies: executionPolicies } = getFargateExecutionRole(`${serviceName}-${version}-execution`, executionRolePolicies || {}, existingExecutionRole);
|
|
145
157
|
dependsOn.push(...executionPolicies);
|
|
146
|
-
const { role: taskRole, policies } = getFargateTaskRole(`${serviceName}-${version}-task`, taskRolePolicies || {});
|
|
158
|
+
const { role: taskRole, policies } = getFargateTaskRole(`${serviceName}-${version}-task`, taskRolePolicies || {}, existingTaskRole);
|
|
147
159
|
dependsOn.push(...policies);
|
|
148
160
|
let dockerLabels = {};
|
|
149
161
|
if (metrics && (metrics.port || dockerListeningPort)) {
|