Amazon web services Cfn林特:不动产;ExecutionRoleArn“;在Resources/TaskDefinition/Properties/ExecutionRoleArn/Ref中没有对资源的有效引用
我正在构建一个cloudformation模板,以便在AWS上运行ECS群集和ECS任务 此外,我正在使用带有插件Cfn Lint的Atom文本编辑器 如图所示,我在Atom文本编辑器中面临以下cfn linter验证问题 共享一些代码片段Amazon web services Cfn林特:不动产;ExecutionRoleArn“;在Resources/TaskDefinition/Properties/ExecutionRoleArn/Ref中没有对资源的有效引用,amazon-web-services,amazon-cloudformation,atom-editor,amazon-ecs,Amazon Web Services,Amazon Cloudformation,Atom Editor,Amazon Ecs,我正在构建一个cloudformation模板,以便在AWS上运行ECS群集和ECS任务 此外,我正在使用带有插件Cfn Lint的Atom文本编辑器 如图所示,我在Atom文本编辑器中面临以下cfn linter验证问题 共享一些代码片段 Resources: # A role needed by ECS ExecutionRole: Type: AWS::IAM::Role Properties: RoleName: !Join ['', [!Ref S
Resources:
# A role needed by ECS
ExecutionRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Join ['', [!Ref ServiceName, ExecutionRole]]
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [ecs-tasks.amazonaws.com]
Action: ['sts:AssumeRole']
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy'
TaskDefinition:
Type: AWS::ECS::TaskDefinition
# Makes sure the log group is created before it is used.
Properties:
# Name of the task definition. Subsequent versions of the task definition are grouped together under this name.
Family: !Join ['', [!Ref ServiceName, TaskDefinition]]
# awsvpc is required for Fargate
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
# 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB
# 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB
# 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB
# 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments
# 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments
Cpu: "2048"
# 0.5GB, 1GB, 2GB - Available cpu values: 256 (.25 vCPU)
# 1GB, 2GB, 3GB, 4GB - Available cpu values: 512 (.5 vCPU)
# 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB - Available cpu values: 1024 (1 vCPU)
# Between 4GB and 16GB in 1GB increments - Available cpu values: 2048 (2 vCPU)
# Between 8GB and 30GB in 1GB increments - Available cpu values: 4096 (4 vCPU)
Memory: 8GB
# A role needed by ECS.
# "The ARN of the task execution role that containers in this task can assume. All containers in this task are granted the permissions that are specified in this role."
# "There is an optional task execution IAM role that you can specify with Fargate to allow your Fargate tasks to make API calls to Amazon ECR."
ExecutionRoleArn: !Ref ExecutionRole
最后一行代码ExecutionRoleArn:!Ref ExecutionRole
给出了Cfn Lint Atom插件中的错误
尽管模板成功运行并创建部署。要获取
Arn
,您必须使用intristic功能:
ExecutionRoleArn: !GetAtt ExecutionRole.Arn
要获取
Arn
,必须使用提示功能:
ExecutionRoleArn: !GetAtt ExecutionRole.Arn