如何自动禁用路径和资产的 AWS CDK 元数据?
How do I disable AWS CDK Metadata for path and assets automatically?
CDK 正在写入 CFN 的元数据有 3 种类型。版本、路径和资产。
有关于如何禁用版本元数据的文档并且它工作正常,但我正在努力解决其余的问题。 CLI 选项 --path-metadata false --asset-metadata false 工作正常,但有点烦人。
我已经通过 CDK 源代码试图找出要插入 cdk.json 的关键字,但它们被忽略了。以下是详细的 cdk 输出,它读取我的设置并且似乎忽略了我关心的 2。
cdk.json: {
"app": "python app.py",
"versionReporting": false, <-- custom, works as intended
"assetMetadata": false, <-- custom, doesn't seem to do anything
"pathMetadata": false, <-- custom, doesn't seem to do anything
"context": {
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
"@aws-cdk/core:stackRelativeExports": "true",
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
"@aws-cdk/aws-lambda:recognizeVersionProps": true,
"@aws-cdk/core:bootstrapQualifier": "myQualifier",
"aws:cdk:enable-path-metadata": false, <-- custom, produces namespace warnings
"aws:cdk:enable-asset-metadata": false, <-- custom, produces namespace warnings
}
}
merged settings: { <------------results of combined settings
versionReporting: false, <-- worked
pathMetadata: true, <--didn't work
output: 'cdk.out',
app: 'python app.py',
assetMetadata: true, <--didn't work
context: {
'@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId': true,
'@aws-cdk/core:stackRelativeExports': 'true',
'@aws-cdk/aws-rds:lowercaseDbIdentifier': true,
'@aws-cdk/aws-lambda:recognizeVersionProps': true,
'@aws-cdk/core:bootstrapQualifier': 'myQualifier',
'aws:cdk:enable-path-metadata': false, <-- seems like a dud
'aws:cdk:enable-asset-metadata': false,<-- seems like a dud
},
debug: false,
profile: 'mycdkIAMUser',
toolkitBucket: {},
staging: true,
bundlingStacks: [ 'my-cdk-policies' ],
lookups: true
}
查看 CDK 源代码,似乎 CLI 选项目前是唯一可行的选项。
看看execProgram() lines 23 to 31:
const pathMetadata: boolean = config.settings.get(['pathMetadata']) ?? true;
if (pathMetadata) {
context[cxapi.PATH_METADATA_ENABLE_CONTEXT] = true;
}
const assetMetadata: boolean = config.settings.get(['assetMetadata']) ?? true;
if (assetMetadata) {
context[cxapi.ASSET_RESOURCE_METADATA_ENABLED_CONTEXT] = true;
}
CLI 选项都默认为 true,然后覆盖它们各自的上下文变量。可能保证 a bug report.
CDK 正在写入 CFN 的元数据有 3 种类型。版本、路径和资产。 有关于如何禁用版本元数据的文档并且它工作正常,但我正在努力解决其余的问题。 CLI 选项 --path-metadata false --asset-metadata false 工作正常,但有点烦人。
我已经通过 CDK 源代码试图找出要插入 cdk.json 的关键字,但它们被忽略了。以下是详细的 cdk 输出,它读取我的设置并且似乎忽略了我关心的 2。
cdk.json: {
"app": "python app.py",
"versionReporting": false, <-- custom, works as intended
"assetMetadata": false, <-- custom, doesn't seem to do anything
"pathMetadata": false, <-- custom, doesn't seem to do anything
"context": {
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
"@aws-cdk/core:stackRelativeExports": "true",
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
"@aws-cdk/aws-lambda:recognizeVersionProps": true,
"@aws-cdk/core:bootstrapQualifier": "myQualifier",
"aws:cdk:enable-path-metadata": false, <-- custom, produces namespace warnings
"aws:cdk:enable-asset-metadata": false, <-- custom, produces namespace warnings
}
}
merged settings: { <------------results of combined settings
versionReporting: false, <-- worked
pathMetadata: true, <--didn't work
output: 'cdk.out',
app: 'python app.py',
assetMetadata: true, <--didn't work
context: {
'@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId': true,
'@aws-cdk/core:stackRelativeExports': 'true',
'@aws-cdk/aws-rds:lowercaseDbIdentifier': true,
'@aws-cdk/aws-lambda:recognizeVersionProps': true,
'@aws-cdk/core:bootstrapQualifier': 'myQualifier',
'aws:cdk:enable-path-metadata': false, <-- seems like a dud
'aws:cdk:enable-asset-metadata': false,<-- seems like a dud
},
debug: false,
profile: 'mycdkIAMUser',
toolkitBucket: {},
staging: true,
bundlingStacks: [ 'my-cdk-policies' ],
lookups: true
}
查看 CDK 源代码,似乎 CLI 选项目前是唯一可行的选项。
看看execProgram() lines 23 to 31:
const pathMetadata: boolean = config.settings.get(['pathMetadata']) ?? true;
if (pathMetadata) {
context[cxapi.PATH_METADATA_ENABLE_CONTEXT] = true;
}
const assetMetadata: boolean = config.settings.get(['assetMetadata']) ?? true;
if (assetMetadata) {
context[cxapi.ASSET_RESOURCE_METADATA_ENABLED_CONTEXT] = true;
}
CLI 选项都默认为 true,然后覆盖它们各自的上下文变量。可能保证 a bug report.