【发布时间】:2021-02-27 18:28:55
【问题描述】:
运行cdk deploy 我收到以下错误消息:
CREATE_FAILED | AWS::ImageBuilder::InfrastructureConfiguration | TestInfrastructureConfiguration 为参数“instanceProfileName”提供的值无效。提供的实例配置文件不存在。请指定不同的实例配置文件,然后重试。 (服务:Imagebuilder,状态码:400,请求 ID:41f431d7-8544-48e9-9faf-a870b83b0100,扩展请求 ID:null)
C# 代码如下所示:
var instanceProfile = new CfnInstanceProfile(this, "TestInstanceProfile", new CfnInstanceProfileProps {
InstanceProfileName = "test-instance-profile",
Roles = new string[] { "TestServiceRoleForImageBuilder" }
});
var infrastructureConfiguration = new CfnInfrastructureConfiguration(this, "TestInfrastructureConfiguration", new CfnInfrastructureConfigurationProps {
Name = "test-infrastructure-configuration",
InstanceProfileName = instanceProfile.InstanceProfileName,
InstanceTypes = new string[] { "t2.medium" },
Logging = new CfnInfrastructureConfiguration.LoggingProperty {
S3Logs = new CfnInfrastructureConfiguration.S3LogsProperty {
S3BucketName = "s3-test-assets",
S3KeyPrefix = "ImageBuilder/Logs"
}
},
SubnetId = "subnet-12f3456f",
SecurityGroupIds = new string[] { "sg-12b3e4e5b67f8900f" }
});
TestServiceRoleForImageBuilder 存在并且之前可以正常工作。大约一个月前,相同的代码已成功运行。有什么建议吗?
如果我删除 CfninfrastructureConfiguration 创建部分,部署会成功运行:但至少需要 2 分钟才能完成。
AwsImageBuilderStack:正在部署... AwsImageBuilderStack:创建 CloudFormation 变更集... 0/3 | 14:24:37 | REVIEW_IN_PROGRESS | AWS::CloudFormation::Stack | AwsImageBuilderStack 用户启动 0/3 | 14:24:43 | CREATE_IN_PROGRESS | AWS::CloudFormation::Stack | AwsImageBuilderStack 用户启动 0/3 | 14:24:47 | CREATE_IN_PROGRESS | AWS::CDK::元数据 | CDK元数据/默认(CDK元数据) 0/3 | 14:24:47 | CREATE_IN_PROGRESS | AWS::IAM::InstanceProfile |测试实例配置文件 0/3 | 14:24:47 | CREATE_IN_PROGRESS | AWS::IAM::InstanceProfile | TestInstanceProfile 资源创建已启动 1/3 | 14:24:48 | CREATE_IN_PROGRESS | AWS::CDK::元数据 | CDKMetadata/Default (CDKMetadata) 资源创建已启动 1/3 | 14:24:48 |创建_完成 | AWS::CDK::元数据 | CDK元数据/默认(CDK元数据) 1/3 目前正在进行中:AwsImageBuilderStack、TestInstanceProfile 3/3 | 14:26:48 |创建_完成 | AWS::IAM::InstanceProfile |测试实例配置文件 3/3 | 14:26:49 |创建_完成 | AWS::CloudFormation::Stack | AwsImageBuilderStack
这可能是某种竞争条件吗?我应该使用多个堆栈来实现我的目标吗?
是否可以使用等待条件 (AWS::CloudFormation::WaitCondition) 绕过 2 分钟的创建时间,以防万一 (AWS::IAM::InstanceProfile resources always take exactly 2 minutes to create)?
环境
- CDK CLI 版本: 1.73.0
- Node.js 版本: 14.13.0
- 操作系统: Windows 10
- 语言(版本): C# (.NET Core 3.1)
更新
由于原因似乎是 AWS 内部的,因此我使用预先创建的实例配置文件作为解决方法。可以通过 IAM 管理控制台或 CLI 创建配置文件。不过最好有合适的解决方案。
【问题讨论】:
标签: amazon-cloudformation amazon-iam aws-cdk