Skip to content

Commit

Permalink
Merge branch 'main' into rds-mysql-version-3-04-1
Browse files Browse the repository at this point in the history
  • Loading branch information
shimi7o authored Nov 15, 2023
2 parents bb6cc4c + db21fef commit dcca54f
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 1 deletion.
78 changes: 78 additions & 0 deletions .github/workflows/update-metadata-regions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Update Metadata Regions
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

jobs:
update-regions:
name: Update Regions
runs-on: ubuntu-latest
steps:
- name: Download regions
env:
URL: https://d3mqmgkwnwa8vm.cloudfront.net/regions.json
id: download
run: |
response=$(curl $URL)
echo "REGIONS=${response}" >> "$GITHUB_OUTPUT"
status=$(curl -s -o /dev/null -w "%{http_code}" $URL)
echo "STATUS=${status}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v3
- uses: actions/github-script@v7
if: ${{ steps.download.outputs.STATUS == 200 }}
env:
REGIONS: ${{ steps.download.outputs.REGIONS }}
with:
script: |
const script = require('./scripts/update-metadata-regions.js')
script()
- name: Create Patch
run: |-
git add .
git diff --patch --staged > ${{ runner.temp }}/update-spec.patch
- name: Upload Patch
uses: actions/upload-artifact@v3
with:
name: update-spec.patch
path: ${{ runner.temp }}/update-spec.patch

pr:
name: Create Pull Request
needs: update-regions
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v4

- name: Download patch
uses: actions/download-artifact@v3
with:
name: update-spec.patch
path: ${{ runner.temp }}

- name: Apply patch
run: '[ -s ${{ runner.temp }}/update-spec.patch ] && git apply ${{ runner.temp }}/update-spec.patch || echo "Empty patch. Skipping."'

- name: Make Pull Request
uses: peter-evans/create-pull-request@v5
with:
# Git commit details
branch: automation/region-update
author: aws-cdk-automation <aws-cdk-automation@users.noreply.github.com>
commit-message: |-
feat(region-info): update Metadata regions
Update the list of regions where the CDK deploys the `AWS::CDK::Metadata` resource.
# Pull Request details
title: "feat(region-info): update Metadata regions"
body: |-
Update the list of regions where the CDK deploys the `AWS::CDK::Metadata` resource.
labels: contribution/core,dependencies,auto-approve,pr-linter/exempt-integ-test,pr-linter/exempt-readme,pr-linter/exempt-test
team-reviewers: aws-cdk-team
# Github prevents further Github actions to be run if the default Github token is used.
# Instead use a privileged token here, so further GH actions can be triggered on this PR.
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-lambda-nodejs/lib/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface NodejsFunctionProps extends lambda.FunctionOptions {
* The runtime environment. Only runtimes of the Node.js family are
* supported.
*
* @default Runtime.NODEJS_18_X
* @default `Runtime.NODEJS_LATEST` if the `@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion` feature flag is enabled, otherwise `Runtime.NODEJS_16_X`
*/
readonly runtime?: lambda.Runtime;

Expand Down
26 changes: 26 additions & 0 deletions scripts/update-metadata-regions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = () => {
const fs= require('fs');
const regions = JSON.parse(process.env.REGIONS);
const content = generateFileContent(regions);
const path = './packages/aws-cdk-lib/region-info/build-tools/metadata.ts';
fs.writeFileSync(path, content);
}

function generateFileContent(regions) {
const template = `/*
* Do not edit this file manually. To prevent misconfiguration, this file
* should only be modified by an automated GitHub workflow, that ensures
* that the regions present in this list correspond to all the regions
* where we have the AWS::CDK::Metadata handler deployed.
*
* See: https://github.com/aws/aws-cdk/issues/27189
*/
export const AWS_CDK_METADATA = new Set([
$REGIONS
]);
`;

const list = regions.sort().map(r => ` '${r}',`).join('\n');
return template.replace('$REGIONS', list);
}

0 comments on commit dcca54f

Please sign in to comment.