这个错误通常表示在AWS ECS Fargate平台中出现了密钥或注册表认证的问题。以下是解决该问题的可能方法之一,包含代码示例:
{
"containerDefinitions": [
{
"name": "my-container",
"image": "your-registry-url/image:tag",
"secrets": [
{
"name": "my-secret",
"valueFrom": "arn:aws:ssm:region:account-id:parameter/parameter-name"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "your-log-group",
"awslogs-region": "region",
"awslogs-stream-prefix": "your-stream-prefix"
}
}
}
]
}
对于密钥,您可以使用以下IAM策略示例:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowParameterRead",
"Effect": "Allow",
"Action": "ssm:GetParameters",
"Resource": "arn:aws:ssm:region:account-id:parameter/parameter-name"
}
]
}
对于注册表,您可以使用以下IAM策略示例:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowECRRead",
"Effect": "Allow",
"Action": [
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:GetRepositoryPolicy",
"ecr:DescribeRepositories",
"ecr:ListImages",
"ecr:DescribeImages",
"ecr:BatchGetImage"
],
"Resource": "*"
}
]
}
请根据您的具体需求和环境进行适当的调整。
这是一个示例IAM角色策略,用于访问密钥和注册表:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowParameterRead",
"Effect": "Allow",
"Action": "ssm:GetParameters",
"Resource": "arn:aws:ssm:region:account-id:parameter/parameter-name"
},
{
"Sid": "AllowECRRead",
"Effect": "Allow",
"Action": [
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:GetRepositoryPolicy",
"ecr:DescribeRepositories",
"ecr:ListImages",
"ecr:DescribeImages",
"ecr:BatchGetImage"
],
"Resource": "*"
}
]
}
请注意,上述代码示例中的"region"、"account-id"、"parameter-name"和"your-registry-url"需要根据您的实际情况进行替换。
希望这些信息能够帮助您解决AWS ECS Fargate平台1.4错误"ResourceInitializationError: Failed to pull key or registry authentication: Error executing resource." 如果问题仍然存在,请考虑查看AWS文档或向AWS支持寻求进一步的帮助。