我们运行一个将 python CDK 代码版本 1.91.0 合成到 Cloudformation 模板并执行它们的 CodePipline。
目前我正在尝试设置一个 Transit Gateway 并与组织和一些帐户共享它。创建基本共享没有问题,但只要我添加了一个中转网关的 resource_arn(注意我是出于测试目的静态进行的),Cloudformation 模板验证失败,声称合成的 Json 模板格式不正确。在最后 }我使用纯 Json 验证器、云形成构建器和 CLI aws cloudformation 验证器验证了完整的 json 模板,它绝对没问题。
所以我可能会在这里遇到一个极端情况,或者对 Transit Gateway Arn 做一些根本错误的事情。
from aws_cdk import (
aws_ram as ram,
)
ram.CfnResourceShare(
self,
id="TransitGWRessourceShare",
name="TransitGWRessourceShare",
allow_external_principals=False,
principals=[
"arn:aws:organizations::1234567890:ou/o-123456asdf/ou-123-asbasdf",
"1234567890",
],
resource_arns=[
"arn:aws:ec2:eu-central-1:1234567890:transit-gateway/tgw-XXXX",
],
)
经过大量的尝试,我发现资源arn导致了问题,并且使用合成json模板的猫,我能够揭示 在合成时添加了一些神秘的点··
Codepipline Step 的 Cat 输出
"TransitGW": {
"Type": "AWS::EC2::TransitGateway",
"Properties": {
"AmazonSideAsn": XXXX,
"AutoAcceptSharedAttachments": "enable",
"DefaultRouteTableAssociation": "disable",
"DefaultRouteTablePropagation": "disable",
"DnsSupport": "enable",
"MulticastSupport": "disable",
],
"VpnEcmpSupport": "enable"
},
},
"TransitGWRessourceShare": {
"Type": "AWS::RAM::ResourceShare",
"Properties": {
"Name": "TransitGWRessourceShare",
"AllowExternalPrincipals": false,
"Principals": [
"arn:aws:organizations::123456789:ou/o-xxxx/ou-xxxx-xxxx",
"123456789"
],
"ResourceArns": [
"arn:aws:ec2:eu-central-1:··1234567890:transit-gateway/tgw-XXXX"
]
},
"Metadata": {
"aws:cdk:path": "automation-cicd/dev/InfraBase/TransitGWRessourceShare"
}
},
任何帮助表示赞赏