将环境变量添加到 Cloudformation ECS + Fargate 部署
Adding environment variable to Cloudformation ECS + Fargate deployment
我们的图像具有应该在 docker 运行 期间定义的环境变量,知道如何将这些变量添加到 cloudformation 文件中。我们目前有类似的东西:
Task:
Type: AWS::ECS::TaskDefinition
Properties:
Family: testenv
Cpu: 256
Memory: 512
NetworkMode:
RequiresCompatibilities:
- FARGATE
ExecutionRoleArn: !ImportValue ECSTaskExecutionRole
ContainerDefinitions:
- Name: bonalds
Image: gcr.io/zonalds-21/id-me:latest // image comes from gcr
Cpu: 256
Memory: 512
PortMappings:
- ContainerPort: 4567
Protocol: tcp
LogConfiguration:
LogDriver:
Options:
awslogs-group: 'zonalds'
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: 'routme'
我在 AWS 文档中似乎找不到任何信息,添加环境变量的最佳方法是什么?
您的容器定义可以包含环境变量。
ContainerDefinitions:
- Name: bonalds
Image: gcr.io/zonalds-21/id-me:latest // image comes from gcr
Cpu: 256
Environment:
- Name: Test
Value: 'test'
Memory: 512
PortMappings:
- ContainerPort: 4567
Protocol: tcp
LogConfiguration:
LogDriver:
Options:
awslogs-group: 'zonalds'
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: 'routme'
更多信息在 doc
我们的图像具有应该在 docker 运行 期间定义的环境变量,知道如何将这些变量添加到 cloudformation 文件中。我们目前有类似的东西:
Task:
Type: AWS::ECS::TaskDefinition
Properties:
Family: testenv
Cpu: 256
Memory: 512
NetworkMode:
RequiresCompatibilities:
- FARGATE
ExecutionRoleArn: !ImportValue ECSTaskExecutionRole
ContainerDefinitions:
- Name: bonalds
Image: gcr.io/zonalds-21/id-me:latest // image comes from gcr
Cpu: 256
Memory: 512
PortMappings:
- ContainerPort: 4567
Protocol: tcp
LogConfiguration:
LogDriver:
Options:
awslogs-group: 'zonalds'
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: 'routme'
我在 AWS 文档中似乎找不到任何信息,添加环境变量的最佳方法是什么?
您的容器定义可以包含环境变量。
ContainerDefinitions:
- Name: bonalds
Image: gcr.io/zonalds-21/id-me:latest // image comes from gcr
Cpu: 256
Environment:
- Name: Test
Value: 'test'
Memory: 512
PortMappings:
- ContainerPort: 4567
Protocol: tcp
LogConfiguration:
LogDriver:
Options:
awslogs-group: 'zonalds'
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: 'routme'
更多信息在 doc