BUGFIX: Give ECS permission to grab private repo secret

This commit is contained in:
Layla 2020-07-31 21:05:06 -04:00
parent a57c16a69e
commit a9e6eb3387
No known key found for this signature in database
GPG Key ID: A494D9357BA1BE31

View File

@ -46,9 +46,41 @@ Parameters:
Conditions:
CreateSecret: !Equals [!Ref NakamaPasswordOverride, ""]
NoRepositoryCredentials: !Equals [!Ref RepositoryCredentialsSecret, ""]
RepositoryCredentials: !Not [!Equals [!Ref RepositoryCredentialsSecret, ""]]
Resources:
EcsExecutionerRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Action:
- sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/CloudWatchLogsFullAccess
EcsExecutionPolicy:
Condition: RepositoryCredentials
Type: AWS::IAM::Policy
Properties:
PolicyName: AllowGettingSecrets
Roles:
- !Ref EcsExecutionerRole
PolicyDocument:
Statement:
- Sid: ReadDockerSecret
Action:
- secretsmanager:Describe*
- secretsmanager:Get*
- secretsmanager:List*
Effect: Allow
Resource: !Ref RepositoryCredentialsSecret
AdminPortalPassword:
Type: AWS::SecretsManager::Secret
Condition: CreateSecret
@ -68,6 +100,7 @@ Resources:
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
ExecutionRoleArn: !Ref EcsExecutionerRole
ContainerDefinitions:
- !If
- NoRepositoryCredentials