【发布时间】:2019-12-28 03:22:00
【问题描述】:
我需要为 IAM 策略添加一些元数据到 Cloudformation。如何使用 CDK 做到这一点?
我正在使用 CDK 来合成 cloudformation,我需要包含一个元数据来抑制 cfn-nag (https://github.com/stelligent/cfn_nag) 警告。
我使用以下语句生成策略:
const cfnCustomPolicy = new iam.CfnPolicy(scope,
'cfnCustomPolicy',
{
policyName: "CustomPolicy",
policyDocument: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Action: "apigateway:GET",
Resource: [
"arn:aws:apigateway:us-east-1::/restapis/*/stages/*/exports/*"
]
}
]
}
}
);
cfnCustomPolicy.cfnOptions.metadata = {
cfn_nag: {
rules_to_suppress: [
{
id: "W12",
reason: "The lambda need access to export documents from any API"
}
]
}
}
有没有更好的方法使用 CDK 来做到这一点,而不使用 L1 接口?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation amazon-iam aws-cdk