|
2 | 2 | { |
3 | 3 | "AWSTemplateFormatVersion" : "2010-09-09", |
4 | 4 | "Conditions": { |
| 5 | + "DedicatedRole": { "Fn::Not":[{"Fn::Equals":[{"Ref":"Policies"},""]} ] }, |
5 | 6 | "EnableCloudWatch": { "Fn::Equals": [ { "Ref": "LogDriver" }, "CloudWatch" ] }, |
6 | 7 | "EnableSyslog": { "Fn::Equals": [ { "Ref": "LogDriver" }, "Syslog" ] }, |
7 | 8 | "FargateEither": { "Fn::Or": [ { "Condition": "FargateBase" }, { "Condition": "FargateSpot" } ] }, |
|
51 | 52 | "Memory": { |
52 | 53 | "Type": "Number" |
53 | 54 | }, |
| 55 | + "Policies": { |
| 56 | + "Description": "It will create a new role to be used instead of 'ServiceRole' parameter.", |
| 57 | + "Type": "String" |
| 58 | + }, |
54 | 59 | "Rack": { |
55 | 60 | "Type": "String" |
56 | 61 | }, |
|
159 | 164 | } ] |
160 | 165 | } |
161 | 166 | }, |
| 167 | + "DedicatedRole": { |
| 168 | + "Condition": "DedicatedRole", |
| 169 | + "Type": "AWS::IAM::Role", |
| 170 | + "Properties": { |
| 171 | + "AssumeRolePolicyDocument": { |
| 172 | + "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "ecs-tasks.amazonaws.com" ] }, "Action": [ "sts:AssumeRole" ] } ], |
| 173 | + "Version": "2012-10-17" |
| 174 | + }, |
| 175 | + "ManagedPolicyArns": {"Fn::Split":[",",{"Fn::Join":[",",[{"Ref":"Policies"},{"Fn::ImportValue":{"Fn::Sub":"${Rack}:CMKPolicy"}}]]}]}, |
| 176 | + "Path": "/convox/", |
| 177 | + "Policies": [ { |
| 178 | + "PolicyName": "convox-env", |
| 179 | + "PolicyDocument": { |
| 180 | + "Version": "2012-10-17", |
| 181 | + "Statement": [ |
| 182 | + { "Effect": "Allow", "Action": "s3:GetObject", "Resource": { "Fn::Sub": "arn:${AWS::Partition}:s3:::${Settings}/*" } }, |
| 183 | + { "Effect": "Allow", "Action": "kms:Decrypt", "Resource": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:EncryptionKey" } } } |
| 184 | + ] |
| 185 | + } |
| 186 | + } ] |
| 187 | + } |
| 188 | + }, |
162 | 189 | "TaskDefinition": { |
163 | 190 | "Type": "AWS::ECS::TaskDefinition", |
164 | 191 | "Properties": { |
|
272 | 299 | "Memory": { "Fn::If": [ "FargateEither", { "Ref": "Memory" }, { "Ref": "AWS::NoValue" } ] }, |
273 | 300 | "NetworkMode": { "Fn::If": [ "FargateEither", "awsvpc", { "Ref": "AWS::NoValue" } ] }, |
274 | 301 | "RequiresCompatibilities": [ { "Fn::If": [ "FargateEither", "FARGATE", { "Ref": "AWS::NoValue" } ] } ], |
275 | | - "TaskRoleArn": { "Ref": "ServiceRole" }, |
| 302 | + "TaskRoleArn": { "Fn::If": [ "DedicatedRole", { "Fn::GetAtt": [ "DedicatedRole", "Arn" ] }, { "Ref": "ServiceRole" } ] }, |
276 | 303 | "Volumes": [ |
277 | 304 | {{ $resources := ($.Manifest.Service .Service).Resources }} |
278 | 305 | {{ range $i, $v := ($.Manifest.Service .Service).Volumes }} |
|
0 commit comments