amazon-cloudformation - 为参数“instanceProfileName”提供的值无效
问题描述
运行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:: 元数据 | CDKMetadata/Default (CDKMetadata) 1/3 当前进行中:AwsImageBuilderStack、TestInstanceProfile 3/3 | 14:26:48 | 创建_完成 | AWS::IAM::InstanceProfile | TestInstanceProfile 3/3 | 14:26:49 | 创建_完成 | AWS::CloudFormation::Stack | AwsImageBuilderStack
可能是某种比赛条件?我应该使用多个堆栈来实现我的目标吗?
是否可以使用等待条件(AWS::CloudFormation::WaitCondition)来绕过 2 分钟的创建时间(AWS::IAM::InstanceProfile 资源总是需要 2 分钟才能创建)?
环境
- CDK CLI 版本: 1.73.0
- Node.js 版本: 14.13.0
- 操作系统: Windows 10
- 语言(版本): C#(.NET Core 3.1)
更新
由于原因似乎是 AWS 内部的,因此我使用预先创建的实例配置文件作为解决方法。可以通过 IAM 管理控制台或 CLI 创建配置文件。但是,有一个适当的解决方案会很好。
解决方案
您必须在两个构造之间创建依赖关系。CDK 在使用可选名称参数时不会推断它,而不是逻辑 id(在这种情况下似乎不起作用)。
infrastructureConfiguration.node.addDependency(instanceProfile)
以下是相关文档:https ://docs.aws.amazon.com/cdk/api/latest/docs/core-readme.html#construct-dependencies
推荐阅读
- python - 如何在 Python 中将 json str 转换为数据框
- r - 由于内存限制,在 R 中加载 mlr 包时出现问题
- python - PythonShell 在 ElasticBeanstalk 上不起作用
- javascript - 如何向 jQuery 动画计数器添加小数?
- three.js - 如何合并文本、球体和盒子几何?
- javascript - React 应用程序在部署到 github 页面后显示空白页面
- javascript - TailwindCSS 活动链接文本颜色未更改
- c# - 错误:sequence contains no element 最近我们升级到 .NetFramework 4.7.2 t 4.8 版本
- python - 触发 Selenium 点击功能后无法获取标签文本
- r - 如何从向量中找到字符串的所有最长匹配项