Looking to set a specified container image based on the selection of a parameter; say if the selection is "aceptance" the container image would point to the acceptance branch image, or "deploy" would point to deploy, etc..
Here is one attempt I have tried, but not sure if this is the best or allowed path. Upon Creating the Stack I receive an error:
ECSTaskDefinition CREATE_FAILED Invalid request provided: Create TaskDefinition: Container.name should not be null or empty. (Service: AmazonECS; Status Code: 400; Error Code: ClientException; Request ID: b679c7be-ad3e-4791-b388-d2cb87332b94; Proxy: null)
Parameters:
Branch:
Type: String
AllowedValues:
- acceptance
- canary
- deploy
Mappings:
BranchSelection:
acceptance:
BranchType: "${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/acceptance"
canary:
BranchType: "${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/canary"
deploy:
BranchType: "${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/deploy"
ECSTaskDefinition:
Type: "AWS::ECS::TaskDefinition"
Properties:
ContainerDefinitions:
-
Environment:
-
Name: "ACCESS_KEY_ID"
Value:
!Sub
- "{{resolve:ssm:/doorways/${STAGE}/ACCESS_KEY_ID:1}}"
- { STAGE: !Ref STAGE }
-
Name: "SECRET_ACCESS_KEY"
Value:
!Sub
- "{{resolve:ssm:/doorways/${STAGE}/AWS_SECRET_KEY:1}}"
- { STAGE: !Ref STAGE }
-
Name: "SENDGRID_USERNAME"
Value:
!Sub
- "{{resolve:ssm:/doorways/${STAGE}/SENDGRID_USERNAME:1}}"
- { STAGE: !Ref STAGE }
-
Name: "SENDGRID_PASSWORD"
Value:
!Sub
- "{{resolve:ssm:/doorways/${STAGE}/SENDGRID_PASSWORD:1}}"
- { STAGE: !Ref STAGE }
-
Name: "REGION"
Value: !Ref AWS::Region
-
Essential: true
Image: !FindInMap
- BranchSelection
- !Ref Branch
- BranchType
LogConfiguration:
LogDriver: "awslogs"
Options:
awslogs-group: "/ecs/doorways-task-definition"
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: "ecs"
Name:
!Sub
- 'dw-${FriendlyName}-${SiteId}-${STAGE}'
- { FriendlyName: !Ref FriendlyName, SiteId: !Ref SiteId, STAGE: !Ref STAGE }
PortMappings:
-
ContainerPort: 3000
HostPort: 3000
Protocol: "tcp"
-
Has anyone had a similar use case, and could possibly point me in the right direction?
Environment must have at least one:
Name: String
Value: String
You don't have any. Also your FindInMap
will not work they way you think it will. The values ${AWS::AccountId}
and ${AWS::Region}
will not be substituted and you will end up with literal strings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.