Skip to content

Commit 9f1fc15

Browse files
authored
chore(cfnspec): support us-west-2 only services (#23928)
Some AWS services are only in us-west-2 region, while CDK uses the AWS CloudFormation resource specification from us-east-1 for generating L1. This change adds suppport for resource specifications from additional regions, with an explicit allow list for services supported for this region. Fixes #17893 Fixes #22565 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 0757f67 commit 9f1fc15

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

packages/@aws-cdk/cfnspec/build-tools/spec-diff.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ async function main() {
1818
const newSpec = await fs.readJSON(newSpecFile);
1919
const oldSpec = await fs.readJSON(oldSpecFile);
2020

21+
// Diff operates on PropertyTypes & ResourceTypes
22+
// Ensure they always exist in the old spec
23+
if (!oldSpec.PropertyTypes) {
24+
oldSpec.PropertyTypes = {};
25+
}
26+
if (!oldSpec.ResourceTypes) {
27+
oldSpec.ResourceTypes = {};
28+
}
29+
2130
const out = jsonDiff(oldSpec, newSpec);
2231

2332
// Here's the magic output format of this thing

packages/@aws-cdk/cfnspec/build-tools/split-spec-by-service.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ import { writeSorted } from './patch-set';
1818
import { CfnSpec, CfnSpecValidator, formatErrorInContext } from './validate-cfn';
1919

2020
async function main(args: string[]) {
21-
if (args.length < 2) {
22-
throw new Error('Usage: split-spec-by-service <SPECFILE> <DIRECTORY>');
21+
if (args.length < 3) {
22+
throw new Error('Usage: split-spec-by-service <SPECFILE> <DIRECTORY> [<SERVICES>]');
2323
}
2424

25-
const [specFile, outDir] = args;
25+
const [specFile, outDir, services] = args;
26+
const allowedServices = services.trim().split(' ').filter(Boolean);
27+
2628
log(`Loading specification: ${specFile}`);
2729
const spec: CfnSpec = await fs.readJson(specFile);
2830

@@ -39,8 +41,17 @@ async function main(args: string[]) {
3941
}
4042

4143
// Write out
42-
log('Writing');
44+
if (allowedServices.length > 0) {
45+
log(`Writing: ${allowedServices.join(' ')}`);
46+
} else {
47+
log('Writing all services');
48+
}
4349
for (const [svcName, svcSpec] of Object.entries(byService)) {
50+
// Skip services that are not explicitly allowed
51+
if (allowedServices.length > 0 && !allowedServices.includes(svcName)) {
52+
continue;
53+
}
54+
4455
const successTarget = path.join(outDir, `000_${svcName}.json`);
4556
const rejectedTarget = path.join(outDir, `.000_${svcName}.rejected.json`);
4657

packages/@aws-cdk/cfnspec/build-tools/update.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function update-spec() {
1616
local targetdir=$3
1717
local gunzip=$4
1818
local split=$5
19+
local services=${@:6}
1920

2021
local tmpdir="$(mktemp -d)"
2122
local newspec="${tmpdir}/new_proposed.json"
@@ -42,10 +43,11 @@ function update-spec() {
4243

4344
# Calculate the old and new combined specs, so we can do a diff on the changes
4445
echo >&2 "Updating source spec..."
46+
mkdir -p ${targetdir}
4547

4648
node build-tools/patch-set.js --quiet "${targetdir}" "${oldcombined}"
4749
if ${split}; then
48-
node build-tools/split-spec-by-service.js "${newspec}" "${targetdir}"
50+
node build-tools/split-spec-by-service.js "${newspec}" "${targetdir}" "${services}"
4951
else
5052
cp "${newspec}" "${targetdir}/spec.json"
5153
sort-json "${targetdir}/spec.json"
@@ -66,6 +68,12 @@ update-spec \
6668
spec-source/specification/000_cfn/000_official \
6769
true true
6870

71+
update-spec \
72+
"CloudFormation Resource Specification (us-west-2)" \
73+
"${2:-https://d201a2mn26r7lk.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json}" \
74+
spec-source/specification/001_cfn_us-west-2/000_official \
75+
true true AWS_DeviceFarm
76+
6977
old_version=$(cat cfn.version)
7078
new_version=$(node -p "require('${scriptdir}/../spec-source/specification/000_cfn/000_official/001_Version.json').ResourceSpecificationVersion")
7179
echo >&2 "Recording new version..."
@@ -76,6 +84,7 @@ echo "$new_version" > cfn.version
7684
if [[ "$new_version" != "$old_version" ]]; then
7785
echo >&2 "Reporting outdated specs..."
7886
node build-tools/report-issues spec-source/specification/000_cfn/000_official/ outdated >> CHANGELOG.md.new
87+
node build-tools/report-issues spec-source/specification/001_cfn_us-west-2/000_official/ outdated >> CHANGELOG.md.new
7988
fi
8089

8190
update-spec \

0 commit comments

Comments
 (0)