Convert AWS CloudFormation Resource Specification to OpenAPI 3.0.0
Follow the steps below to generate OpenAPI specs and a StackQL provider for AWS Cloud Control using CloudFormation schemas.
sh provider-dev/scripts/download-and-preprocess-defs.shsh provider-dev/scripts/get_cc_supported_resources.sh(requires AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY env vars to be set)
npm run generate-provideroutput openapi3 specs (components/schemas) are written to opneapi/src/aws/v00.00.00000/services
PROVIDER_REGISTRY_ROOT_DIR="$(pwd)/openapi"
npm run start-server -- --provider awscc --registry $PROVIDER_REGISTRY_ROOT_DIR
npm run test-meta-routes -- awscc --ignore-no-methods
npm run stop-servernpm run test-meta-routes -- awscc --ignore-no-methods
- ensure the
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYenvironment variables are set - download the latest
stackqlbinary, for examplecurl -L https://bit.ly/stackql-zip -O && unzip stackql-zipfor Linux systems - run the following:
PROVIDER_REGISTRY_ROOT_DIR="$(pwd)"
REG_STR='{"url": "file://'${PROVIDER_REGISTRY_ROOT_DIR}/openapi'", "localDocRoot": "'${PROVIDER_REGISTRY_ROOT_DIR}/openapi'", "verifyConfig": {"nopVerify": true}}'
./stackql shell --registry="${REG_STR}"- run
stackqlcommands, for example
select * from awscc.s3.buckets_list_only WHERE region = 'us-east-1';
select bucket_name, region, bucket_encryption from awscc.s3.buckets WHERE region = 'us-east-1' and data__Identifier = 'stackql-trial-bucket-01';npm run generate-docsoutput markdown docs are written to website/docs
cd website
# test build
yarn build
# run local dev server
yarn startUnder Pages in the repository, in the Build and deployment section select GitHub Actions as the Source. In Netlify DNS create the following records:
| Source Domain | Record Type | Target |
|---|---|---|
| awscc-provider.stackql.io | CNAME | stackql.github.io. |
To troubleshoot AWS Cloud Control API requests (mutation requests), use the following queries:
select * from aws.cloud_control.resource_requests
where data__ResourceRequestStatusFilter = '{"OperationStatuses": ["FAILED"], "Operations": ["CREATE"]}'
and region = 'ap-southeast-2';
--or
select * from aws.cloud_control.resource_requests
where data__ResourceRequestStatusFilter = '{"OperationStatuses": ["FAILED"], "Operations": ["DELETE"]}'
and region = 'us-east-1';
--or
select * from aws.cloud_control.resource_requests
where data__ResourceRequestStatusFilter = '{"OperationStatuses": ["SUCCESS"], "Operations": ["UPDATE"]}'
and region = 'ap-southeast-2';(replace region accordingly)
select * from aws.cloud_control.resource_request
where data__RequestToken = '54061545-e0a0-4ef0-b213-41fda81d8c24'
and region = 'ap-southeast-2';(replace region and data__RequestToken accordingly)
To resolve resource identifiers you can use tags, such as:
SELECT
json_extract(value, '$.ResourceARN') as arn
FROM awscc.tagging.tagged_resources, json_each(ResourceTagMappingList)
WHERE
region = 'us-east-1'
AND data__TagFilters = '[
{"Key": "StackName","Values": ["stackql-serverless"]},
{"Key": "StackEnv","Values": ["prd"]}
]'
AND data__TagsPerPage = 100;See here for newly added or updated Cloud Control resources.
MIT