gpt4 book ai didi

amazon-web-services - ECS 从 EC2 迁移到 Fargate

转载 作者:行者123 更新时间:2023-12-04 08:11:01 25 4
gpt4 key购买 nike

我正在尝试从 Amazon ECS EC2 迁移到 Fargate。在这里,我根据 https://aws.amazon.com/blogs/compute/migrating-your-amazon-ecs-containers-to-aws-fargate/ 的建议做了一些更改。 。我正在使用 amazon cloudformation 来创建/更新资源。

ECSTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family : !Join ["_", [!Ref "AppName", !Ref "ComponentName", !Ref "TargetEnv" ]]
NetworkMode: "awsvpc"
ExecutionRoleArn: arn:aws:iam::${AWS::AccountId}:role/ecsTaskExecutionRole
TaskRoleArn:
Fn::Sub:
[
"arn:aws:iam::${AWS::AccountId}:role/exec_dp_${TargetEnv}",
{
TargetEnv: !Ref "TargetEnv"
}
]
RequiresCompatibilities:
- "FARGATE"
Memory: "512"
Cpu: '256'
ContainerDefinitions:

这里的问题是,当我尝试创建堆栈时,它给出了如下错误:

Unable to assume the service linked role. Please verify that the ECS service linked role exists

我还尝试创建服务链接角色,如下所示:

AwsEcsTaskExecutionRole:
Type: AWS::IAM::Role
Properties:
Path: /
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: ecs.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/aws-service-role/AmazonECSServiceRolePolicy

然后将其指定为ExecutionRoleArn:!GetAtt AwsEcsTaskExecutionRole.Arn

它不工作。任何有关的方向都会真正有帮助。

最佳答案

简短回答:

运行此命令:aws iam create-service-linked-role --aws-service-name ecs.amazonaws.com

长答案:

AWS推出Service-Linked Roles 。对于旧的 AWS 账户或者如果您从未在控制台中手动创建过 ECS 集群,则必须运行上面的命令来创建角色。

关于amazon-web-services - ECS 从 EC2 迁移到 Fargate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49686385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com