diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d9c6bd3f256..dc1281e5388 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -35,8 +35,10 @@ jobs:
version: ${{ fromJson(steps.changelog.outputs.data).newVersion }}
last-version: ${{ fromJson(steps.changelog.outputs.data).lastVersion }}
changelog: ${{ fromJson(steps.changelog.outputs.data).changelog }}
- vscode-wing-changed: ${{ steps.git-diff-vscode-wing.outputs.diff }}
-
+ vscode-wing-changed: ${{ fromJson(steps.turbo-diff.outputs.data)['vscode-wing#compile'].changes }}
+ console-changed: ${{ fromJson(steps.turbo-diff.outputs.data)['@wingconsole/app#preview:fly'].changes }}
+ e2e-changed: ${{ fromJson(steps.turbo-diff.outputs.data)['hangar#test'].changes }}
+ bench-changed: ${{ fromJson(steps.turbo-diff.outputs.data)['hangar#bench'].changes }}
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -72,58 +74,34 @@ jobs:
- name: Install Dependencies
run: pnpm install --frozen-lockfile
+ - name: Derive appropriate SHAs for base and head
+ id: shas
+ uses: nrwl/nx-set-shas@v3
+
+ - name: Figure out what projects changed
+ id: turbo-diff
+ run: pnpm turbo-diff --startRef ${{ steps.shas.outputs.base }} --endRef ${{ steps.shas.outputs.head }}
+
- name: Changelog Generation
id: changelog
env:
GENERATE_VERSION: ${{ github.event_name != 'push' || github.repository != 'winglang/wing' }}
- run: pnpm changelog
+ run: pnpm bump-pack
- name: Build and Package
run: pnpm package:ci
env:
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}
- - name: Derive appropriate SHAs for base and head
- id: setSHAs
- uses: nrwl/nx-set-shas@v3
-
- - name: Check git diff of VSCode Extension
- id: git-diff-vscode-wing
- run: |
- if git diff --quiet ${{ steps.setSHAs.outputs.base }} ${{ github.sha }} -- apps/vscode-wing; then
- echo "diff=false" >> "$GITHUB_OUTPUT"
- else
- echo "diff=true" >> "$GITHUB_OUTPUT"
- fi
-
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/*
- # Create patch to go from the PR head to the merge commit
- - name: Create git patch for merge
- if: github.event_name == 'pull_request'
- id: diff
- run: |
- git diff --binary --patch ${{ github.event.pull_request.head.sha }} ${{ github.sha }} > update.diff
- if [ -s update.diff ]; then
- echo "Diff found, creating a patch to apply later"
- cat update.diff
- echo "diff=true" >> $GITHUB_OUTPUT
- fi
-
- - name: Upload patch
- if: steps.diff.outputs.diff == 'true'
- uses: actions/upload-artifact@v3
- with:
- name: update.diff
- path: update.diff
-
test:
name: Test
- timeout-minutes: 30
+ timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -164,14 +142,7 @@ jobs:
- name: Create git patch
id: diff
- run: |
- git add --all
- git diff --staged --binary --patch > build.diff
- if [ -s build.diff ]; then
- echo "Diff found, creating a patch to apply later"
- cat build.diff
- echo "diff=true" >> $GITHUB_OUTPUT
- fi
+ run: scripts/create_patch.sh build.diff
- name: Upload patch
if: steps.diff.outputs.diff == 'true'
@@ -182,6 +153,7 @@ jobs:
benchmark:
name: Benchmark
+ if: needs.build.outputs.bench-changed == 'true' || contains(github.event.pull_request.labels.*.name, 'đ§Ș pr/e2e-full')
runs-on: ubuntu-latest
needs:
- build
@@ -227,6 +199,7 @@ jobs:
runs-on: "${{ matrix.runner }}-latest"
needs:
- build
+ if: needs.build.outputs.e2e-changed == 'true' || contains(github.event.pull_request.labels.*.name, 'đ§Ș pr/e2e-full')
strategy:
fail-fast: true
matrix:
@@ -282,13 +255,7 @@ jobs:
RAW_SHARD: ${{ matrix.shard }}
run: |
SHARD=$(echo $RAW_SHARD | sed 's/\//of/g')
- DIFF_NAME="e2e-$SHARD.diff"
- git add --all
- git diff --staged --binary --patch > $DIFF_NAME
- if [ -s $DIFF_NAME ]; then
- echo "diff=true" >> $GITHUB_OUTPUT
- echo "diff_name=$DIFF_NAME" >> $GITHUB_OUTPUT
- fi
+ scripts/create_patch.sh "e2e-$SHARD.diff"
- name: Upload mutation
if: matrix.runner == 'ubuntu' && matrix.node == '18' && steps.diff.outputs.diff == 'true'
@@ -297,26 +264,74 @@ jobs:
name: ${{ steps.diff.outputs.diff_name }}
path: ${{ steps.diff.outputs.diff_name }}
+ console-preview:
+ name: "Console Preview"
+ runs-on: ubuntu-latest
+ needs:
+ - build
+ env:
+ FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
+ FLY_VERSION: "0.1.80"
+ APP_NAME: wing-console-pr-${{github.event.number}}
+ if: ${{ needs.build.outputs.console-changed == 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'mergify/merge-queue/') }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+
+ - name: Download Dist Artifacts
+ uses: actions/download-artifact@v3
+ with:
+ name: dist
+ path: dist
+
+ - name: Install flyctl
+ uses: superfly/flyctl-actions/setup-flyctl@1.4
+ with:
+ version: ${{ env.FLY_VERSION }}
+
+ - name: Deploy to Fly.io
+ id: deploy-fly
+ run: |
+ if ! flyctl status --app "$APP_NAME"; then
+ pushd ./apps/wing-console/console/app/preview
+ flyctl launch --no-deploy --copy-config --name "$APP_NAME" --image-label latest
+ popd
+ fi
+ flyctl deploy . --config ./apps/wing-console/console/app/preview/fly.toml --app "$APP_NAME" --image-label latest --vm-memory 512 --strategy immediate
+ flyctl scale count 1 --yes --app "$APP_NAME"
+ echo "deploytime=$(TZ=UTC date +'%Y-%m-%d %H:%M')" >> $GITHUB_OUTPUT
+
+ - name: Post preview comment
+ uses: thollander/actions-comment-pull-request@v2
+ with:
+ message: |
+ Console preview environment is available at https://${{env.APP_NAME}}.fly.dev :rocket:
+
+ *Updated (UTC): ${{steps.deploy-fly.outputs.deploytime }}*
+ comment_tag: Console preview environment
+ GITHUB_TOKEN: ${{secrets.PROJEN_GITHUB_TOKEN}}
+
quality-gate:
name: Quality Gate
runs-on: ubuntu-latest
+ if: ${{ !cancelled() }}
needs:
- build
- e2e-test
- benchmark
- test
steps:
+ - name: Check failure
+ if: needs.build.result == 'failure' || needs.e2e-test.result == 'failure' || needs.benchmark.result == 'failure' || needs.test.result == 'failure'
+ run: exit 1
- name: Download patches
uses: actions/download-artifact@v3
- name: Check patches
run: |
PATCH_COUNT=0
for f in $(find ./*.diff/*.diff); do
- # Exclude update.diff since we don't want to fail if the PR is just not up to date
- if [ "$f" != "./update.diff/update.diff" ]; then
- PATCH_COUNT=$((PATCH_COUNT + 1))
- cat $f
- fi
+ PATCH_COUNT=$((PATCH_COUNT + 1))
+ cat $f
done
if [ $PATCH_COUNT -gt 0 ]; then
echo "Found $PATCH_COUNT patches, build failed. A self-mutation should happen soon."
@@ -327,7 +342,7 @@ jobs:
publish:
name: Publish
- if: ${{ github.event_name == 'push' && github.repository == 'winglang/wing' && github.ref == 'refs/heads/main' }}
+ if: ${{ !cancelled() && needs.quality-gate.result == 'success' && github.event_name == 'push' && github.repository == 'winglang/wing' && github.ref == 'refs/heads/main' }}
needs:
- quality-gate
- build
@@ -351,8 +366,8 @@ jobs:
env:
PACKAGE_VERSION: ${{ needs.build.outputs.version }}
run: |
- PACKAGES=("winglang-sdk" "winglang-compiler" "wingconsole-design-system" "wingconsole-ui" "wingconsole-server" "wingconsole-app")
- for PACKAGE in $PACKAGES; do
+ PACKAGES=("winglang-sdk" "winglang-compiler" "wingconsole-design-system" "wingconsole-ui" "wingconsole-server" "wingconsole-app" "winglang")
+ for PACKAGE in "${PACKAGES[@]}"; do
npm publish "$PACKAGE-$PACKAGE_VERSION.tgz" --access public
done
@@ -374,7 +389,11 @@ jobs:
- name: Compute Checksums
run: |
- mv ./benchmarks/* ./dist
+ # if there is a ./benchmarks/report.json, move it to ./dist
+ if [ -f ./benchmarks/report.json ]; then
+ mv ./benchmarks/report.json ./dist
+ fi
+
cd dist
echo '' >> ../CHANGELOG.md
diff --git a/.github/workflows/delete-console-preview.yml b/.github/workflows/delete-console-preview.yml
new file mode 100644
index 00000000000..6e21b6d6d1c
--- /dev/null
+++ b/.github/workflows/delete-console-preview.yml
@@ -0,0 +1,28 @@
+name: Delete Console Preview
+
+on:
+ pull_request:
+ types:
+ - closed
+
+env:
+ FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
+ FLY_VERSION: "0.1.80"
+ APP_NAME: wing-console-pr-${{github.event.number}}
+
+jobs:
+ destroy:
+ name: "Destroy"
+ runs-on: ubuntu-latest
+ if: ${{ github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'mergify/merge-queue/') }}
+ steps:
+ - name: Install flyctl
+ uses: superfly/flyctl-actions/setup-flyctl@1.4
+ with:
+ version: ${{env.FLY_VERSION}}
+
+ - name: Delete preview environment
+ run: |
+ if flyctl status --app "$APP_NAME"; then
+ flyctl apps destroy "$APP_NAME" -y
+ fi
diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml
index b1a9fe408e1..302a440d5b2 100644
--- a/.github/workflows/mutation.yml
+++ b/.github/workflows/mutation.yml
@@ -21,8 +21,7 @@ permissions:
jobs:
mutate:
runs-on: ubuntu-latest
- # Run if the workflow run is a pull request
- if: github.event.workflow_run.conclusion == 'failure' && (!contains(fromJSON('["main", "dev"]'), github.event.workflow_run.head_branch) || github.event.workflow_run.head_repository.fork)
+ if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' && (!contains(fromJSON('["main", "dev"]'), github.event.workflow_run.head_branch) || github.event.workflow_run.head_repository.fork)
steps:
- name: Download artifacts
id: download-artifacts
@@ -57,18 +56,65 @@ jobs:
run: |
git config --global core.hooksPath /dev/null
+ - name: Update PR Branch
+ uses: actions/github-script@v6
+ if: github.event.workflow_run.event == 'pull_request' && steps.download-artifacts.outputs.found_artifact == 'true'
+ with:
+ github-token: ${{ secrets.MUTATION_TOKEN }}
+ script: |
+ // use API to get the PR data since we can't rely on the context across forks
+ const pulls = await github.rest.pulls.list({
+ per_page: 1,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ head: `${context.payload.workflow_run.head_repository.full_name}:${context.payload.workflow_run.head_branch}`
+ });
+
+ const prContextData = pulls.data[0];
+ const prNumber = prContextData.number;
+ const originalSha = prContextData.head.sha;
+
+ try {
+ console.log("Updating PR branch");
+ await github.rest.pulls.updateBranch({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: prNumber
+ });
+ console.log("PR branch updated");
+
+ let updatedSha = originalSha;
+ let retries = 0;
+ const MAX_RETRIES = 10;
+ while (updatedSha == originalSha && retries++ < MAX_RETRIES) {
+ console.log(`Waiting for PR branch to update (attempt ${retries}/${MAX_RETRIES})`);
+
+ await new Promise(r => setTimeout(r, 500));
+ const updatedPR = await github.rest.pulls.get({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: prNumber
+ });
+ updatedSha = updatedPR.data.head.sha;
+ }
+ } catch (error) {
+ // The branch is already up to date or can't otherwise be updated
+ // That's fine, we tried our best
+ console.warn(error);
+ }
+
- name: Checkout Workflow Branch
if: steps.download-artifacts.outputs.found_artifact == 'true'
uses: actions/checkout@v3
with:
- token: ${{secrets.MUTATION_TOKEN}}
+ token: ${{ secrets.MUTATION_TOKEN }}
ref: ${{ github.event.workflow_run.head_branch }}
repository: ${{ github.event.workflow_run.head_repository.full_name }}
path: repo
- id: self_mutation
if: steps.download-artifacts.outputs.found_artifact == 'true'
- name: Apply downloaded pathes
+ name: Apply downloaded patches
working-directory: repo
env:
HEAD_REF: ${{ github.event.workflow_run.head_branch }}
@@ -76,29 +122,12 @@ jobs:
git config user.name "monada-bot[bot]"
git config user.email "monabot@monada.co"
- # if ../patches/update.diff/update.diff exists, apply it first
- UPDATE_PATCH_FILE="../patches/update.diff/update.diff"
- if [ -f $UPDATE_PATCH_FILE ]; then
- echo "Updating branch"
- git apply --binary $UPDATE_PATCH_FILE
- if [ $? -eq 0 ]; then
- git add --all
- git commit -s -m "Merge branch 'main' into $HEAD_REF"
- echo "Patch applied successfully"
- rm $UPDATE_PATCH_FILE
- else
- echo "Patch failed to apply"
- cat $UPDATE_PATCH_FILE
- exit 1
- fi
- fi
-
for f in $(find ../patches/*.diff/*.diff); do
echo "Applying $f"
git apply --binary $f
if [ $? -eq 0 ]; then
git add --all
- git commit -s -m "chore: self mutation ($f)"
+ git commit -s -m "chore: self mutation ($(basename $f))"
echo "Patch applied successfully"
rm $f
else
@@ -116,12 +145,13 @@ jobs:
with:
github-token: ${{ secrets.MUTATION_TOKEN }}
script: |
+ // use API to get the PR number since we can't rely on the context across forks
const pulls = await github.rest.pulls.list({
+ per_page: 1,
owner: context.repo.owner,
repo: context.repo.repo,
head: `${context.payload.workflow_run.head_repository.full_name}:${context.payload.workflow_run.head_branch}`
});
-
const prNumber = pulls.data[0].number;
const labels = ["â ïž pr/review-mutation"];
diff --git a/.gitignore b/.gitignore
index 233e1f9b1c1..c41313fee1d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
node_modules/
+.pnpm-store/
+
# Terraform state files
*.tfstate
*.tfstate.*
diff --git a/Cargo.lock b/Cargo.lock
index 801e7812fc1..af7e617453b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -133,6 +133,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
+[[package]]
+name = "camino"
+version = "1.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c"
+
[[package]]
name = "cc"
version = "1.0.81"
@@ -1667,6 +1673,7 @@ name = "wingc"
version = "0.1.0"
dependencies = [
"aho-corasick 0.7.20",
+ "camino",
"colored",
"const_format",
"derivative",
@@ -1696,6 +1703,7 @@ name = "wingii"
version = "0.1.0"
dependencies = [
"blake3",
+ "camino",
"filetime",
"flate2",
"rand",
diff --git a/apps/jsii-docgen/.projen/tasks.json b/apps/jsii-docgen/.projen/tasks.json
index 96f7a5f2fe6..f31cc816fd4 100644
--- a/apps/jsii-docgen/.projen/tasks.json
+++ b/apps/jsii-docgen/.projen/tasks.json
@@ -165,7 +165,7 @@
"exec": "npm-check-updates --dep dev --upgrade --target=minor --reject='jsii'"
},
{
- "exec": "npm-check-updates --dep optional --upgrade --target=minor --reject='jsii'"
+ "exec": "npm-check-updates --dep bundle --upgrade --target=minor --reject='jsii'"
},
{
"exec": "npm-check-updates --dep peer --upgrade --target=minor --reject='jsii'"
@@ -174,13 +174,13 @@
"exec": "npm-check-updates --dep prod --upgrade --target=minor --reject='jsii'"
},
{
- "exec": "npm-check-updates --dep bundle --upgrade --target=minor --reject='jsii'"
+ "exec": "npm-check-updates --dep optional --upgrade --target=minor --reject='jsii'"
},
{
"exec": "pnpm i --no-frozen-lockfile"
},
{
- "exec": "pnpm update"
+ "exec": "pnpm update @types/fs-extra @types/jest @types/node @types/semver @types/yargs @typescript-eslint/eslint-plugin @typescript-eslint/parser constructs eslint-config-prettier eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint jest jest-junit jsii npm-check-updates prettier projen ts-jest ts-node typescript @jsii/spec case fs-extra glob glob-promise jsii-reflect jsii-rosetta semver yargs"
},
{
"exec": "pnpm exec projen"
@@ -201,7 +201,7 @@
}
},
"env": {
- "PATH": "$(pnpm -c exec \"node -e \\\"console.log(process.env.PATH)\\\"\")",
+ "PATH": "$(pnpm -c exec \"node --print process.env.PATH\")",
"NODE_OPTIONS": "--max-old-space-size=7168"
},
"//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"."
diff --git a/apps/jsii-docgen/package.json b/apps/jsii-docgen/package.json
index 71150788d1d..e709d162934 100644
--- a/apps/jsii-docgen/package.json
+++ b/apps/jsii-docgen/package.json
@@ -35,36 +35,36 @@
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.5.2",
"@types/node": "^16",
- "@types/semver": "^7.3.13",
+ "@types/semver": "^7.5.1",
"@types/yargs": "^16",
"@typescript-eslint/eslint-plugin": "^5",
"@typescript-eslint/parser": "^5",
- "constructs": "^10.2.5",
+ "constructs": "^10.2.70",
"eslint": "^8",
- "eslint-config-prettier": "^8.6.0",
- "eslint-import-resolver-node": "^0.3.7",
- "eslint-import-resolver-typescript": "^3.5.3",
- "eslint-plugin-import": "^2.27.5",
+ "eslint-config-prettier": "^8.10.0",
+ "eslint-import-resolver-node": "^0.3.9",
+ "eslint-import-resolver-typescript": "^3.6.0",
+ "eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^4.2.1",
- "jest": "^27",
+ "jest": "^27.5.1",
"jest-junit": "^15",
"jsii": "~5.0.0",
"npm-check-updates": "^16",
- "prettier": "^2.8.3",
- "projen": "^0.71.60",
- "ts-jest": "^27",
+ "prettier": "^2.8.8",
+ "projen": "^0.71.163",
+ "ts-jest": "^27.1.5",
"ts-node": "^10.9.1",
- "typescript": "~4.9.4"
+ "typescript": "~4.9.5"
},
"dependencies": {
- "@jsii/spec": "^1.73.0",
+ "@jsii/spec": "^1.88.0",
"case": "^1.6.3",
"fs-extra": "^10.1.0",
"glob": "^8.1.0",
- "glob-promise": "^6.0.2",
- "jsii-reflect": "^1.73.0",
- "jsii-rosetta": "^1.73.0",
- "semver": "^7.3.8",
+ "glob-promise": "^6.0.3",
+ "jsii-reflect": "^1.88.0",
+ "jsii-rosetta": "^1.88.0",
+ "semver": "^7.5.4",
"yargs": "^16"
},
"main": "lib/index.js",
diff --git a/apps/jsii-docgen/src/docgen/transpile/transpile.ts b/apps/jsii-docgen/src/docgen/transpile/transpile.ts
index e7bd685c294..efff36ae4e5 100644
--- a/apps/jsii-docgen/src/docgen/transpile/transpile.ts
+++ b/apps/jsii-docgen/src/docgen/transpile/transpile.ts
@@ -275,6 +275,11 @@ export interface TranspiledParameter {
* supports that.
*/
readonly declaration: string;
+
+ /**
+ * Is the parameter variadic
+ */
+ readonly variadic?: boolean;
}
/**
diff --git a/apps/jsii-docgen/src/docgen/transpile/wing.ts b/apps/jsii-docgen/src/docgen/transpile/wing.ts
index 4d1b5e826c6..d95a4f2dbc1 100644
--- a/apps/jsii-docgen/src/docgen/transpile/wing.ts
+++ b/apps/jsii-docgen/src/docgen/transpile/wing.ts
@@ -174,6 +174,7 @@ export class WingTranspile extends transpile.TranspileBase {
parentType: this.type(parameter.parentType),
typeReference: typeRef,
optional: parameter.optional,
+ variadic: parameter.spec.variadic,
declaration: this.formatProperty(name, typeRef),
};
}
@@ -280,7 +281,14 @@ export class WingTranspile extends transpile.TranspileBase {
if (tf === "Inflight") {
tf = "~Inflight";
}
- return `${transpiled.name}${transpiled.optional ? "?" : ""}: ${tf}`;
+ if (transpiled.variadic) {
+ tf = `Array<${tf}>`;
+ }
+ const name = transpiled.variadic
+ ? `...${transpiled.name}`
+ : transpiled.name;
+
+ return `${name}${transpiled.optional ? "?" : ""}: ${tf}`;
}
private formatProperty(
diff --git a/apps/jsii-docgen/test/__fixtures__/libraries/construct-library/package.json b/apps/jsii-docgen/test/__fixtures__/libraries/construct-library/package.json
index 5307d8f47ee..3a1dcdfc192 100644
--- a/apps/jsii-docgen/test/__fixtures__/libraries/construct-library/package.json
+++ b/apps/jsii-docgen/test/__fixtures__/libraries/construct-library/package.json
@@ -25,28 +25,28 @@
"organization": false
},
"dependencies": {
- "@aws-cdk/aws-s3": "^1.110.1",
- "@aws-cdk/core": "^1.110.1",
- "@aws-cdk/aws-iam": "^1.110.1",
- "@aws-cdk/aws-kms": "^1.110.1",
- "@aws-cdk/aws-events": "^1.110.1",
- "@aws-cdk/cloud-assembly-schema": "^1.110.1",
- "constructs": "^3.3.69"
+ "@aws-cdk/aws-events": "^1.204.0",
+ "@aws-cdk/aws-iam": "^1.204.0",
+ "@aws-cdk/aws-kms": "^1.204.0",
+ "@aws-cdk/aws-s3": "^1.204.0",
+ "@aws-cdk/cloud-assembly-schema": "^1.204.0",
+ "@aws-cdk/core": "^1.204.0",
+ "constructs": "^3.4.344"
},
"peerDependencies": {
- "@aws-cdk/aws-s3": "^1.110.1",
- "@aws-cdk/core": "^1.110.1",
- "@aws-cdk/aws-iam": "^1.110.1",
- "@aws-cdk/aws-kms": "^1.110.1",
- "@aws-cdk/aws-events": "^1.110.1",
- "@aws-cdk/cloud-assembly-schema": "^1.110.1",
+ "@aws-cdk/aws-events": "^1.204.0",
+ "@aws-cdk/aws-iam": "^1.204.0",
+ "@aws-cdk/aws-kms": "^1.204.0",
+ "@aws-cdk/aws-s3": "^1.204.0",
+ "@aws-cdk/cloud-assembly-schema": "^1.204.0",
+ "@aws-cdk/core": "^1.204.0",
"constructs": "^3.3.69"
},
"devDependencies": {
- "@types/node": "^18.0.0",
+ "@types/node": "^18.17.13",
"@types/prettier": "2.6.0",
- "jsii": "~5.0.0",
- "typescript": "^4.3.4"
+ "jsii": "~5.0.21",
+ "typescript": "^4.9.5"
},
"license": "Apache-2.0",
"version": "0.0.0"
diff --git a/apps/jsii-docgen/test/__snapshots__/cli.test.ts.snap b/apps/jsii-docgen/test/__snapshots__/cli.test.ts.snap
index ab0997fbc2d..89ae002f2e1 100644
--- a/apps/jsii-docgen/test/__snapshots__/cli.test.ts.snap
+++ b/apps/jsii-docgen/test/__snapshots__/cli.test.ts.snap
@@ -49,7 +49,7 @@ new submod1.GoodbyeBucket(scope: Construct, id: string, props?: BucketProps)
| addEventNotification | Adds a bucket notification event destination. |
| addObjectCreatedNotification | Subscribes a destination to receive notifications when an object is created in the bucket. |
| addObjectRemovedNotification | Subscribes a destination to receive notifications when an object is removed from the bucket. |
-| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
+| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
| arnForObjects | Returns an ARN that represents all objects within the bucket that match the key pattern specified. |
| grantDelete | Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket. |
| grantPublicAccess | Allows unrestricted access to objects from this bucket. |
@@ -61,9 +61,10 @@ new submod1.GoodbyeBucket(scope: Construct, id: string, props?: BucketProps)
| onCloudTrailEvent | Define a CloudWatch event that triggers when something happens to this repository. |
| onCloudTrailPutObject | Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call. |
| onCloudTrailWriteObject | Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to. |
-| s3UrlForObject | The S3 URL of an S3 object. |
-| urlForObject | The https URL of an S3 object. |
-| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. |
+| s3UrlForObject | The S3 URL of an S3 object. For example:. |
+| transferAccelerationUrlForObject | The https Transfer Acceleration URL of an S3 object. |
+| urlForObject | The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:. |
+| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:. |
| addCorsRule | Adds a cross-origin access configuration for objects in an Amazon S3 bucket. |
| addInventory | Add an inventory configuration. |
| addLifecycleRule | Add a lifecycle rule to the bucket. |
@@ -85,7 +86,7 @@ being managed by CloudFormation, either because you've removed it from the
CDK application or because you've made a change that requires the resource
to be replaced.
-The resource can be deleted (\`RemovalPolicy.DELETE\`), or left in your AWS
+The resource can be deleted (\`RemovalPolicy.DESTROY\`), or left in your AWS
account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
###### \`policy\`Required
@@ -107,7 +108,9 @@ Adds a bucket notification event destination.
*Example*
\`\`\`typescript
- bucket.addEventNotification(EventType.OnObjectCreated, myLambda, 'home/myusername/*')
+ declare const myLambda: lambda.Function;
+ const bucket = new s3.Bucket(this, 'MyBucket');
+ bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});
\`\`\`
@@ -148,7 +151,7 @@ public addObjectCreatedNotification(dest: IBucketNotificationDestination, filter
Subscribes a destination to receive notifications when an object is created in the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectCreated)\`.
+\`onEvent(EventType.OBJECT_CREATED)\`.
###### \`dest\`Required
@@ -175,7 +178,7 @@ public addObjectRemovedNotification(dest: IBucketNotificationDestination, filter
Subscribes a destination to receive notifications when an object is removed from the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectRemoved)\`.
+\`onEvent(EventType.OBJECT_REMOVED)\`.
###### \`dest\`Required
@@ -199,12 +202,20 @@ Filters (see onEvent).
public addToResourcePolicy(permission: PolicyStatement): AddToResourcePolicyResult
\`\`\`
-Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+
+Note that the policy statement may or may not be added to the policy.
+For example, when an \`IBucket\` is created from an existing bucket,
+it's not possible to tell whether the bucket already has a policy
+attached, let alone to re-use that policy to add more statements to it.
+So it's safest to do nothing in these cases.
###### \`permission\`Required
- *Type:* @aws-cdk/aws-iam.PolicyStatement
+the policy statement to be added to the bucket's policy.
+
---
##### \`arnForObjects\`
@@ -274,6 +285,10 @@ to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });
+Note that if this \`IBucket\` refers to an existing bucket, possibly not
+managed by CloudFormation, this method will have no effect, since it's
+impossible to modify the policy of an existing bucket.
+
###### \`allowedActions\`Required
- *Type:* string
@@ -530,45 +545,66 @@ Options for adding the rule.
public s3UrlForObject(key?: string): string
\`\`\`
-The S3 URL of an S3 object.
+The S3 URL of an S3 object. For example:.
-For example:
+\`s3://onlybucket\`
+- \`s3://bucket/key\`
-*Example*
+###### \`key\`Optional
+
+- *Type:* string
+
+The S3 key of the object.
+
+If not specified, the S3 URL of the
+bucket is returned.
+
+---
+
+##### \`transferAccelerationUrlForObject\`
\`\`\`typescript
-s3://bucket/key
+public transferAccelerationUrlForObject(key?: string, options?: TransferAccelerationUrlOptions): string
\`\`\`
+The https Transfer Acceleration URL of an S3 object.
-###### \`key\`Optional
+Specify \`dualStack: true\` at the options
+for dual-stack endpoint (connect to the bucket over IPv6). For example:
+
+- \`https://bucket.s3-accelerate.amazonaws.com\`
+- \`https://bucket.s3-accelerate.amazonaws.com/key\`
+
+###### \`key\`Optional
- *Type:* string
The S3 key of the object.
-If not specified, the S3 URL of the
+If not specified, the URL of the
bucket is returned.
---
-##### \`urlForObject\`
+###### \`options\`Optional
-\`\`\`typescript
-public urlForObject(key?: string): string
-\`\`\`
+- *Type:* @aws-cdk/aws-s3.TransferAccelerationUrlOptions
-The https URL of an S3 object.
+Options for generating URL.
-Specify \`regional: false\` at the options
-for non-regional URLs. For example:
+---
-*Example*
+##### \`urlForObject\`
\`\`\`typescript
-https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey
+public urlForObject(key?: string): string
\`\`\`
+The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:.
+
+\`https://s3.us-west-1.amazonaws.com/onlybucket\`
+- \`https://s3.us-west-1.amazonaws.com/bucket/key\`
+- \`https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey\`
###### \`key\`Optional
@@ -587,17 +623,12 @@ bucket is returned.
public virtualHostedUrlForObject(key?: string, options?: VirtualHostedStyleUrlOptions): string
\`\`\`
-The virtual hosted-style URL of an S3 object.
-
-Specify \`regional: false\` at
-the options for non-regional URL. For example:
-
-*Example*
-
-\`\`\`typescript
-https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey
-\`\`\`
+The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:.
+\`https://only-bucket.s3.us-west-1.amazonaws.com\`
+- \`https://bucket.s3.us-west-1.amazonaws.com/key\`
+- \`https://bucket.s3.amazonaws.com/key\`
+- \`https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey\`
###### \`key\`Optional
@@ -696,6 +727,7 @@ public goodbye(): void
| fromBucketArn | *No description.* |
| fromBucketAttributes | Creates a Bucket construct that represents an external bucket. |
| fromBucketName | *No description.* |
+| validateBucketName | Thrown an exception if the given bucket name is not valid. |
---
@@ -804,6 +836,24 @@ submod1.GoodbyeBucket.fromBucketName(scope: Construct, id: string, bucketName: s
---
+##### \`validateBucketName\`
+
+\`\`\`typescript
+import { submod1 } from 'construct-library'
+
+submod1.GoodbyeBucket.validateBucketName(physicalName: string)
+\`\`\`
+
+Thrown an exception if the given bucket name is not valid.
+
+###### \`physicalName\`Required
+
+- *Type:* string
+
+name of the bucket.
+
+---
+
#### Properties
| **Name** | **Type** | **Description** |
@@ -1035,7 +1085,7 @@ new GreeterBucket(scope: Construct, id: string, props?: BucketProps)
| addEventNotification | Adds a bucket notification event destination. |
| addObjectCreatedNotification | Subscribes a destination to receive notifications when an object is created in the bucket. |
| addObjectRemovedNotification | Subscribes a destination to receive notifications when an object is removed from the bucket. |
-| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
+| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
| arnForObjects | Returns an ARN that represents all objects within the bucket that match the key pattern specified. |
| grantDelete | Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket. |
| grantPublicAccess | Allows unrestricted access to objects from this bucket. |
@@ -1047,9 +1097,10 @@ new GreeterBucket(scope: Construct, id: string, props?: BucketProps)
| onCloudTrailEvent | Define a CloudWatch event that triggers when something happens to this repository. |
| onCloudTrailPutObject | Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call. |
| onCloudTrailWriteObject | Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to. |
-| s3UrlForObject | The S3 URL of an S3 object. |
-| urlForObject | The https URL of an S3 object. |
-| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. |
+| s3UrlForObject | The S3 URL of an S3 object. For example:. |
+| transferAccelerationUrlForObject | The https Transfer Acceleration URL of an S3 object. |
+| urlForObject | The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:. |
+| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:. |
| addCorsRule | Adds a cross-origin access configuration for objects in an Amazon S3 bucket. |
| addInventory | Add an inventory configuration. |
| addLifecycleRule | Add a lifecycle rule to the bucket. |
@@ -1071,7 +1122,7 @@ being managed by CloudFormation, either because you've removed it from the
CDK application or because you've made a change that requires the resource
to be replaced.
-The resource can be deleted (\`RemovalPolicy.DELETE\`), or left in your AWS
+The resource can be deleted (\`RemovalPolicy.DESTROY\`), or left in your AWS
account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
###### \`policy\`Required
@@ -1093,7 +1144,9 @@ Adds a bucket notification event destination.
*Example*
\`\`\`typescript
- bucket.addEventNotification(EventType.OnObjectCreated, myLambda, 'home/myusername/*')
+ declare const myLambda: lambda.Function;
+ const bucket = new s3.Bucket(this, 'MyBucket');
+ bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});
\`\`\`
@@ -1134,7 +1187,7 @@ public addObjectCreatedNotification(dest: IBucketNotificationDestination, filter
Subscribes a destination to receive notifications when an object is created in the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectCreated)\`.
+\`onEvent(EventType.OBJECT_CREATED)\`.
###### \`dest\`Required
@@ -1161,7 +1214,7 @@ public addObjectRemovedNotification(dest: IBucketNotificationDestination, filter
Subscribes a destination to receive notifications when an object is removed from the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectRemoved)\`.
+\`onEvent(EventType.OBJECT_REMOVED)\`.
###### \`dest\`Required
@@ -1185,12 +1238,20 @@ Filters (see onEvent).
public addToResourcePolicy(permission: PolicyStatement): AddToResourcePolicyResult
\`\`\`
-Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+
+Note that the policy statement may or may not be added to the policy.
+For example, when an \`IBucket\` is created from an existing bucket,
+it's not possible to tell whether the bucket already has a policy
+attached, let alone to re-use that policy to add more statements to it.
+So it's safest to do nothing in these cases.
###### \`permission\`Required
- *Type:* @aws-cdk/aws-iam.PolicyStatement
+the policy statement to be added to the bucket's policy.
+
---
##### \`arnForObjects\`
@@ -1260,6 +1321,10 @@ to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });
+Note that if this \`IBucket\` refers to an existing bucket, possibly not
+managed by CloudFormation, this method will have no effect, since it's
+impossible to modify the policy of an existing bucket.
+
###### \`allowedActions\`Required
- *Type:* string
@@ -1516,45 +1581,66 @@ Options for adding the rule.
public s3UrlForObject(key?: string): string
\`\`\`
-The S3 URL of an S3 object.
+The S3 URL of an S3 object. For example:.
-For example:
+\`s3://onlybucket\`
+- \`s3://bucket/key\`
-*Example*
+###### \`key\`Optional
+
+- *Type:* string
+
+The S3 key of the object.
+
+If not specified, the S3 URL of the
+bucket is returned.
+
+---
+
+##### \`transferAccelerationUrlForObject\`
\`\`\`typescript
-s3://bucket/key
+public transferAccelerationUrlForObject(key?: string, options?: TransferAccelerationUrlOptions): string
\`\`\`
+The https Transfer Acceleration URL of an S3 object.
-###### \`key\`Optional
+Specify \`dualStack: true\` at the options
+for dual-stack endpoint (connect to the bucket over IPv6). For example:
+
+- \`https://bucket.s3-accelerate.amazonaws.com\`
+- \`https://bucket.s3-accelerate.amazonaws.com/key\`
+
+###### \`key\`Optional
- *Type:* string
The S3 key of the object.
-If not specified, the S3 URL of the
+If not specified, the URL of the
bucket is returned.
---
-##### \`urlForObject\`
+###### \`options\`Optional
-\`\`\`typescript
-public urlForObject(key?: string): string
-\`\`\`
+- *Type:* @aws-cdk/aws-s3.TransferAccelerationUrlOptions
-The https URL of an S3 object.
+Options for generating URL.
-Specify \`regional: false\` at the options
-for non-regional URLs. For example:
+---
-*Example*
+##### \`urlForObject\`
\`\`\`typescript
-https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey
+public urlForObject(key?: string): string
\`\`\`
+The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:.
+
+\`https://s3.us-west-1.amazonaws.com/onlybucket\`
+- \`https://s3.us-west-1.amazonaws.com/bucket/key\`
+- \`https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey\`
###### \`key\`Optional
@@ -1573,17 +1659,12 @@ bucket is returned.
public virtualHostedUrlForObject(key?: string, options?: VirtualHostedStyleUrlOptions): string
\`\`\`
-The virtual hosted-style URL of an S3 object.
-
-Specify \`regional: false\` at
-the options for non-regional URL. For example:
-
-*Example*
-
-\`\`\`typescript
-https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey
-\`\`\`
+The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:.
+\`https://only-bucket.s3.us-west-1.amazonaws.com\`
+- \`https://bucket.s3.us-west-1.amazonaws.com/key\`
+- \`https://bucket.s3.amazonaws.com/key\`
+- \`https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey\`
###### \`key\`Optional
@@ -1682,6 +1763,7 @@ public greet(): void
| fromBucketArn | *No description.* |
| fromBucketAttributes | Creates a Bucket construct that represents an external bucket. |
| fromBucketName | *No description.* |
+| validateBucketName | Thrown an exception if the given bucket name is not valid. |
---
@@ -1790,6 +1872,24 @@ GreeterBucket.fromBucketName(scope: Construct, id: string, bucketName: string)
---
+##### \`validateBucketName\`
+
+\`\`\`typescript
+import { GreeterBucket } from 'construct-library'
+
+GreeterBucket.validateBucketName(physicalName: string)
+\`\`\`
+
+Thrown an exception if the given bucket name is not valid.
+
+###### \`physicalName\`Required
+
+- *Type:* string
+
+name of the bucket.
+
+---
+
#### Properties
| **Name** | **Type** | **Description** |
@@ -2007,14 +2107,18 @@ submod1.GoodbyeBucket(
encryption: BucketEncryption = None,
encryption_key: IKey = None,
enforce_ss_l: bool = None,
+ event_bridge_enabled: bool = None,
+ intelligent_tiering_configurations: typing.List[IntelligentTieringConfiguration] = None,
inventories: typing.List[Inventory] = None,
lifecycle_rules: typing.List[LifecycleRule] = None,
metrics: typing.List[BucketMetrics] = None,
+ notifications_handler_role: IRole = None,
object_ownership: ObjectOwnership = None,
public_read_access: bool = None,
removal_policy: RemovalPolicy = None,
server_access_logs_bucket: IBucket = None,
server_access_logs_prefix: str = None,
+ transfer_acceleration: bool = None,
versioned: bool = None,
website_error_document: str = None,
website_index_document: str = None,
@@ -2036,14 +2140,18 @@ submod1.GoodbyeBucket(
| encryption | aws_cdk.aws_s3.BucketEncryption | The kind of server-side encryption to apply to this bucket. |
| encryption_key | aws_cdk.aws_kms.IKey | External KMS key to use for bucket encryption. |
| enforce_ss_l | bool | Enforces SSL for requests. |
+| event_bridge_enabled | bool | Whether this bucket should send notifications to Amazon EventBridge or not. |
+| intelligent_tiering_configurations | typing.List[aws_cdk.aws_s3.IntelligentTieringConfiguration] | Inteligent Tiering Configurations. |
| inventories | typing.List[aws_cdk.aws_s3.Inventory] | The inventory configuration of the bucket. |
| lifecycle_rules | typing.List[aws_cdk.aws_s3.LifecycleRule] | Rules that define how Amazon S3 manages objects during their lifetime. |
| metrics | typing.List[aws_cdk.aws_s3.BucketMetrics] | The metrics configuration of this bucket. |
+| notifications_handler_role | aws_cdk.aws_iam.IRole | The role to be used by the notifications handler. |
| object_ownership | aws_cdk.aws_s3.ObjectOwnership | The objectOwnership of the bucket. |
| public_read_access | bool | Grants public read access to all objects in the bucket. |
| removal_policy | aws_cdk.core.RemovalPolicy | Policy to apply when the bucket is removed from this stack. |
| server_access_logs_bucket | aws_cdk.aws_s3.IBucket | Destination bucket for the server access logs. |
| server_access_logs_prefix | str | Optional log file prefix to use for the bucket's access logs. |
+| transfer_acceleration | bool | Whether this bucket should have transfer acceleration turned on or not. |
| versioned | bool | Whether this bucket should have versioning turned on or not. |
| website_error_document | str | The name of the error document (e.g. \\"404.html\\") for the website. \`websiteIndexDocument\` must also be set if this is set. |
| website_index_document | str | The name of the index document (e.g. \\"index.html\\") for the website. Enables static website hosting for this bucket. |
@@ -2082,6 +2190,11 @@ Whether all objects should be automatically deleted when the bucket is removed f
Requires the \`removalPolicy\` to be set to \`RemovalPolicy.DESTROY\`.
+**Warning** if you have deployed a bucket with \`autoDeleteObjects: true\`,
+switching this to \`false\` in a CDK version *before* \`1.126.0\` will lead to
+all objects in the bucket being deleted. Be sure to update your bucket resources
+by deploying with CDK version \`1.126.0\` or later **before** switching this value to \`false\`.
+
---
##### \`block_public_access\`Optional
@@ -2164,6 +2277,26 @@ S3.5 of the AWS Foundational Security Best Practices Regarding S3.
---
+##### \`event_bridge_enabled\`Optional
+
+- *Type:* bool
+- *Default:* false
+
+Whether this bucket should send notifications to Amazon EventBridge or not.
+
+---
+
+##### \`intelligent_tiering_configurations\`Optional
+
+- *Type:* typing.List[aws_cdk.aws_s3.IntelligentTieringConfiguration]
+- *Default:* No Intelligent Tiiering Configurations.
+
+Inteligent Tiering Configurations.
+
+> [https://docs.aws.amazon.com/AmazonS3/latest/userguide/intelligent-tiering.html](https://docs.aws.amazon.com/AmazonS3/latest/userguide/intelligent-tiering.html)
+
+---
+
##### \`inventories\`Optional
- *Type:* typing.List[aws_cdk.aws_s3.Inventory]
@@ -2195,6 +2328,15 @@ The metrics configuration of this bucket.
---
+##### \`notifications_handler_role\`Optional
+
+- *Type:* aws_cdk.aws_iam.IRole
+- *Default:* a new role will be created.
+
+The role to be used by the notifications handler.
+
+---
+
##### \`object_ownership\`Optional
- *Type:* aws_cdk.aws_s3.ObjectOwnership
@@ -2246,6 +2388,15 @@ If defined without \\"serverAccessLogsBucket\\", enables access logs to current
---
+##### \`transfer_acceleration\`Optional
+
+- *Type:* bool
+- *Default:* false
+
+Whether this bucket should have transfer acceleration turned on or not.
+
+---
+
##### \`versioned\`Optional
- *Type:* bool
@@ -2301,7 +2452,7 @@ Rules that define when a redirect is applied and the redirect behavior.
| add_event_notification | Adds a bucket notification event destination. |
| add_object_created_notification | Subscribes a destination to receive notifications when an object is created in the bucket. |
| add_object_removed_notification | Subscribes a destination to receive notifications when an object is removed from the bucket. |
-| add_to_resource_policy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
+| add_to_resource_policy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
| arn_for_objects | Returns an ARN that represents all objects within the bucket that match the key pattern specified. |
| grant_delete | Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket. |
| grant_public_access | Allows unrestricted access to objects from this bucket. |
@@ -2313,9 +2464,10 @@ Rules that define when a redirect is applied and the redirect behavior.
| on_cloud_trail_event | Define a CloudWatch event that triggers when something happens to this repository. |
| on_cloud_trail_put_object | Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call. |
| on_cloud_trail_write_object | Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to. |
-| s3_url_for_object | The S3 URL of an S3 object. |
-| url_for_object | The https URL of an S3 object. |
-| virtual_hosted_url_for_object | The virtual hosted-style URL of an S3 object. |
+| s3_url_for_object | The S3 URL of an S3 object. For example:. |
+| transfer_acceleration_url_for_object | The https Transfer Acceleration URL of an S3 object. |
+| url_for_object | The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:. |
+| virtual_hosted_url_for_object | The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:. |
| add_cors_rule | Adds a cross-origin access configuration for objects in an Amazon S3 bucket. |
| add_inventory | Add an inventory configuration. |
| add_lifecycle_rule | Add a lifecycle rule to the bucket. |
@@ -2339,7 +2491,7 @@ being managed by CloudFormation, either because you've removed it from the
CDK application or because you've made a change that requires the resource
to be replaced.
-The resource can be deleted (\`RemovalPolicy.DELETE\`), or left in your AWS
+The resource can be deleted (\`RemovalPolicy.DESTROY\`), or left in your AWS
account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
###### \`policy\`Required
@@ -2366,7 +2518,9 @@ Adds a bucket notification event destination.
*Example*
\`\`\`python
- bucket.addEventNotification(EventType.OnObjectCreated, myLambda, 'home/myusername/*')
+ declare const myLambda: lambda.Function;
+ const bucket = new s3.Bucket(this, 'MyBucket');
+ bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});
\`\`\`
@@ -2415,7 +2569,7 @@ def add_object_created_notification(
Subscribes a destination to receive notifications when an object is created in the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectCreated)\`.
+\`onEvent(EventType.OBJECT_CREATED)\`.
###### \`dest\`Required
@@ -2454,7 +2608,7 @@ def add_object_removed_notification(
Subscribes a destination to receive notifications when an object is removed from the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectRemoved)\`.
+\`onEvent(EventType.OBJECT_REMOVED)\`.
###### \`dest\`Required
@@ -2488,12 +2642,20 @@ def add_to_resource_policy(
) -> AddToResourcePolicyResult
\`\`\`
-Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+
+Note that the policy statement may or may not be added to the policy.
+For example, when an \`IBucket\` is created from an existing bucket,
+it's not possible to tell whether the bucket already has a policy
+attached, let alone to re-use that policy to add more statements to it.
+So it's safest to do nothing in these cases.
###### \`permission\`Required
- *Type:* aws_cdk.aws_iam.PolicyStatement
+the policy statement to be added to the bucket's policy.
+
---
##### \`arn_for_objects\`
@@ -2571,6 +2733,10 @@ to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });
+Note that if this \`IBucket\` refers to an existing bucket, possibly not
+managed by CloudFormation, this method will have no effect, since it's
+impossible to modify the policy of an existing bucket.
+
###### \`allowed_actions\`Required
- *Type:* str
@@ -2994,28 +3160,59 @@ def s3_url_for_object(
) -> str
\`\`\`
-The S3 URL of an S3 object.
+The S3 URL of an S3 object. For example:.
-For example:
+\`s3://onlybucket\`
+- \`s3://bucket/key\`
-*Example*
+###### \`key\`Optional
+
+- *Type:* str
+
+The S3 key of the object.
+
+If not specified, the S3 URL of the
+bucket is returned.
+
+---
+
+##### \`transfer_acceleration_url_for_object\`
\`\`\`python
-s3://bucket/key
+def transfer_acceleration_url_for_object(
+ key: str = None,
+ dual_stack: bool = None
+) -> str
\`\`\`
+The https Transfer Acceleration URL of an S3 object.
-###### \`key\`Optional
+Specify \`dualStack: true\` at the options
+for dual-stack endpoint (connect to the bucket over IPv6). For example:
+
+- \`https://bucket.s3-accelerate.amazonaws.com\`
+- \`https://bucket.s3-accelerate.amazonaws.com/key\`
+
+###### \`key\`Optional
- *Type:* str
The S3 key of the object.
-If not specified, the S3 URL of the
+If not specified, the URL of the
bucket is returned.
---
+###### \`dual_stack\`Optional
+
+- *Type:* bool
+- *Default:* false
+
+Dual-stack support to connect to the bucket over IPv6.
+
+---
+
##### \`url_for_object\`
\`\`\`python
@@ -3024,17 +3221,11 @@ def url_for_object(
) -> str
\`\`\`
-The https URL of an S3 object.
-
-Specify \`regional: false\` at the options
-for non-regional URLs. For example:
-
-*Example*
-
-\`\`\`python
-https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey
-\`\`\`
+The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:.
+\`https://s3.us-west-1.amazonaws.com/onlybucket\`
+- \`https://s3.us-west-1.amazonaws.com/bucket/key\`
+- \`https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey\`
###### \`key\`Optional
@@ -3056,17 +3247,12 @@ def virtual_hosted_url_for_object(
) -> str
\`\`\`
-The virtual hosted-style URL of an S3 object.
-
-Specify \`regional: false\` at
-the options for non-regional URL. For example:
-
-*Example*
-
-\`\`\`python
-https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey
-\`\`\`
+The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:.
+\`https://only-bucket.s3.us-west-1.amazonaws.com\`
+- \`https://bucket.s3.us-west-1.amazonaws.com/key\`
+- \`https://bucket.s3.amazonaws.com/key\`
+- \`https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey\`
###### \`key\`Optional
@@ -3254,7 +3440,10 @@ def add_lifecycle_rule(
expired_object_delete_marker: bool = None,
id: str = None,
noncurrent_version_expiration: Duration = None,
+ noncurrent_versions_to_retain: typing.Union[int, float] = None,
noncurrent_version_transitions: typing.List[NoncurrentVersionTransition] = None,
+ object_size_greater_than: typing.Union[int, float] = None,
+ object_size_less_than: typing.Union[int, float] = None,
prefix: str = None,
tag_filters: typing.Mapping[typing.Any] = None,
transitions: typing.List[Transition] = None
@@ -3351,6 +3540,18 @@ transition time.
---
+###### \`noncurrent_versions_to_retain\`Optional
+
+- *Type:* typing.Union[int, float]
+- *Default:* No noncurrent versions to retain
+
+Indicates a maximum number of noncurrent versions to retain.
+
+If there are this many more noncurrent versions,
+Amazon S3 permanently deletes them.
+
+---
+
###### \`noncurrent_version_transitions\`Optional
- *Type:* typing.List[aws_cdk.aws_s3.NoncurrentVersionTransition]
@@ -3364,6 +3565,24 @@ must be later than the transition time.
---
+###### \`object_size_greater_than\`Optional
+
+- *Type:* typing.Union[int, float]
+- *Default:* No rule
+
+Specifies the minimum object size in bytes for this rule to apply to.
+
+---
+
+###### \`object_size_less_than\`Optional
+
+- *Type:* typing.Union[int, float]
+- *Default:* No rule
+
+Specifies the maximum object size in bytes for this rule to apply to.
+
+---
+
###### \`prefix\`Optional
- *Type:* str
@@ -3447,6 +3666,7 @@ def goodbye() -> None
| from_bucket_arn | *No description.* |
| from_bucket_attributes | Creates a Bucket construct that represents an external bucket. |
| from_bucket_name | *No description.* |
+| validate_bucket_name | Thrown an exception if the given bucket name is not valid. |
---
@@ -3516,6 +3736,7 @@ submod1.GoodbyeBucket.from_bucket_attributes(
bucket_website_url: str = None,
encryption_key: IKey = None,
is_website: bool = None,
+ notifications_handler_role: IRole = None,
region: str = None
)
\`\`\`
@@ -3632,6 +3853,15 @@ If this bucket has been configured for static website hosting.
---
+###### \`notifications_handler_role\`Optional
+
+- *Type:* aws_cdk.aws_iam.IRole
+- *Default:* a new role will be created.
+
+The role to be used by the notifications handler.
+
+---
+
###### \`region\`Optional
- *Type:* str
@@ -3671,6 +3901,26 @@ submod1.GoodbyeBucket.from_bucket_name(
---
+##### \`validate_bucket_name\`
+
+\`\`\`python
+from construct_library import submod1
+
+submod1.GoodbyeBucket.validate_bucket_name(
+ physical_name: str
+)
+\`\`\`
+
+Thrown an exception if the given bucket name is not valid.
+
+###### \`physical_name\`Required
+
+- *Type:* str
+
+name of the bucket.
+
+---
+
#### Properties
| **Name** | **Type** | **Description** |
@@ -3877,14 +4127,18 @@ construct_library.GreeterBucket(
encryption: BucketEncryption = None,
encryption_key: IKey = None,
enforce_ss_l: bool = None,
+ event_bridge_enabled: bool = None,
+ intelligent_tiering_configurations: typing.List[IntelligentTieringConfiguration] = None,
inventories: typing.List[Inventory] = None,
lifecycle_rules: typing.List[LifecycleRule] = None,
metrics: typing.List[BucketMetrics] = None,
+ notifications_handler_role: IRole = None,
object_ownership: ObjectOwnership = None,
public_read_access: bool = None,
removal_policy: RemovalPolicy = None,
server_access_logs_bucket: IBucket = None,
server_access_logs_prefix: str = None,
+ transfer_acceleration: bool = None,
versioned: bool = None,
website_error_document: str = None,
website_index_document: str = None,
@@ -3906,14 +4160,18 @@ construct_library.GreeterBucket(
| encryption | aws_cdk.aws_s3.BucketEncryption | The kind of server-side encryption to apply to this bucket. |
| encryption_key | aws_cdk.aws_kms.IKey | External KMS key to use for bucket encryption. |
| enforce_ss_l | bool | Enforces SSL for requests. |
+| event_bridge_enabled | bool | Whether this bucket should send notifications to Amazon EventBridge or not. |
+| intelligent_tiering_configurations | typing.List[aws_cdk.aws_s3.IntelligentTieringConfiguration] | Inteligent Tiering Configurations. |
| inventories | typing.List[aws_cdk.aws_s3.Inventory] | The inventory configuration of the bucket. |
| lifecycle_rules | typing.List[aws_cdk.aws_s3.LifecycleRule] | Rules that define how Amazon S3 manages objects during their lifetime. |
| metrics | typing.List[aws_cdk.aws_s3.BucketMetrics] | The metrics configuration of this bucket. |
+| notifications_handler_role | aws_cdk.aws_iam.IRole | The role to be used by the notifications handler. |
| object_ownership | aws_cdk.aws_s3.ObjectOwnership | The objectOwnership of the bucket. |
| public_read_access | bool | Grants public read access to all objects in the bucket. |
| removal_policy | aws_cdk.core.RemovalPolicy | Policy to apply when the bucket is removed from this stack. |
| server_access_logs_bucket | aws_cdk.aws_s3.IBucket | Destination bucket for the server access logs. |
| server_access_logs_prefix | str | Optional log file prefix to use for the bucket's access logs. |
+| transfer_acceleration | bool | Whether this bucket should have transfer acceleration turned on or not. |
| versioned | bool | Whether this bucket should have versioning turned on or not. |
| website_error_document | str | The name of the error document (e.g. \\"404.html\\") for the website. \`websiteIndexDocument\` must also be set if this is set. |
| website_index_document | str | The name of the index document (e.g. \\"index.html\\") for the website. Enables static website hosting for this bucket. |
@@ -3952,6 +4210,11 @@ Whether all objects should be automatically deleted when the bucket is removed f
Requires the \`removalPolicy\` to be set to \`RemovalPolicy.DESTROY\`.
+**Warning** if you have deployed a bucket with \`autoDeleteObjects: true\`,
+switching this to \`false\` in a CDK version *before* \`1.126.0\` will lead to
+all objects in the bucket being deleted. Be sure to update your bucket resources
+by deploying with CDK version \`1.126.0\` or later **before** switching this value to \`false\`.
+
---
##### \`block_public_access\`Optional
@@ -4034,6 +4297,26 @@ S3.5 of the AWS Foundational Security Best Practices Regarding S3.
---
+##### \`event_bridge_enabled\`Optional
+
+- *Type:* bool
+- *Default:* false
+
+Whether this bucket should send notifications to Amazon EventBridge or not.
+
+---
+
+##### \`intelligent_tiering_configurations\`Optional
+
+- *Type:* typing.List[aws_cdk.aws_s3.IntelligentTieringConfiguration]
+- *Default:* No Intelligent Tiiering Configurations.
+
+Inteligent Tiering Configurations.
+
+> [https://docs.aws.amazon.com/AmazonS3/latest/userguide/intelligent-tiering.html](https://docs.aws.amazon.com/AmazonS3/latest/userguide/intelligent-tiering.html)
+
+---
+
##### \`inventories\`Optional
- *Type:* typing.List[aws_cdk.aws_s3.Inventory]
@@ -4065,6 +4348,15 @@ The metrics configuration of this bucket.
---
+##### \`notifications_handler_role\`Optional
+
+- *Type:* aws_cdk.aws_iam.IRole
+- *Default:* a new role will be created.
+
+The role to be used by the notifications handler.
+
+---
+
##### \`object_ownership\`Optional
- *Type:* aws_cdk.aws_s3.ObjectOwnership
@@ -4116,6 +4408,15 @@ If defined without \\"serverAccessLogsBucket\\", enables access logs to current
---
+##### \`transfer_acceleration\`Optional
+
+- *Type:* bool
+- *Default:* false
+
+Whether this bucket should have transfer acceleration turned on or not.
+
+---
+
##### \`versioned\`Optional
- *Type:* bool
@@ -4171,7 +4472,7 @@ Rules that define when a redirect is applied and the redirect behavior.
| add_event_notification | Adds a bucket notification event destination. |
| add_object_created_notification | Subscribes a destination to receive notifications when an object is created in the bucket. |
| add_object_removed_notification | Subscribes a destination to receive notifications when an object is removed from the bucket. |
-| add_to_resource_policy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
+| add_to_resource_policy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
| arn_for_objects | Returns an ARN that represents all objects within the bucket that match the key pattern specified. |
| grant_delete | Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket. |
| grant_public_access | Allows unrestricted access to objects from this bucket. |
@@ -4183,9 +4484,10 @@ Rules that define when a redirect is applied and the redirect behavior.
| on_cloud_trail_event | Define a CloudWatch event that triggers when something happens to this repository. |
| on_cloud_trail_put_object | Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call. |
| on_cloud_trail_write_object | Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to. |
-| s3_url_for_object | The S3 URL of an S3 object. |
-| url_for_object | The https URL of an S3 object. |
-| virtual_hosted_url_for_object | The virtual hosted-style URL of an S3 object. |
+| s3_url_for_object | The S3 URL of an S3 object. For example:. |
+| transfer_acceleration_url_for_object | The https Transfer Acceleration URL of an S3 object. |
+| url_for_object | The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:. |
+| virtual_hosted_url_for_object | The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:. |
| add_cors_rule | Adds a cross-origin access configuration for objects in an Amazon S3 bucket. |
| add_inventory | Add an inventory configuration. |
| add_lifecycle_rule | Add a lifecycle rule to the bucket. |
@@ -4209,7 +4511,7 @@ being managed by CloudFormation, either because you've removed it from the
CDK application or because you've made a change that requires the resource
to be replaced.
-The resource can be deleted (\`RemovalPolicy.DELETE\`), or left in your AWS
+The resource can be deleted (\`RemovalPolicy.DESTROY\`), or left in your AWS
account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
###### \`policy\`Required
@@ -4236,7 +4538,9 @@ Adds a bucket notification event destination.
*Example*
\`\`\`python
- bucket.addEventNotification(EventType.OnObjectCreated, myLambda, 'home/myusername/*')
+ declare const myLambda: lambda.Function;
+ const bucket = new s3.Bucket(this, 'MyBucket');
+ bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});
\`\`\`
@@ -4285,7 +4589,7 @@ def add_object_created_notification(
Subscribes a destination to receive notifications when an object is created in the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectCreated)\`.
+\`onEvent(EventType.OBJECT_CREATED)\`.
###### \`dest\`Required
@@ -4324,7 +4628,7 @@ def add_object_removed_notification(
Subscribes a destination to receive notifications when an object is removed from the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectRemoved)\`.
+\`onEvent(EventType.OBJECT_REMOVED)\`.
###### \`dest\`Required
@@ -4358,12 +4662,20 @@ def add_to_resource_policy(
) -> AddToResourcePolicyResult
\`\`\`
-Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+
+Note that the policy statement may or may not be added to the policy.
+For example, when an \`IBucket\` is created from an existing bucket,
+it's not possible to tell whether the bucket already has a policy
+attached, let alone to re-use that policy to add more statements to it.
+So it's safest to do nothing in these cases.
###### \`permission\`Required
- *Type:* aws_cdk.aws_iam.PolicyStatement
+the policy statement to be added to the bucket's policy.
+
---
##### \`arn_for_objects\`
@@ -4441,6 +4753,10 @@ to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });
+Note that if this \`IBucket\` refers to an existing bucket, possibly not
+managed by CloudFormation, this method will have no effect, since it's
+impossible to modify the policy of an existing bucket.
+
###### \`allowed_actions\`Required
- *Type:* str
@@ -4864,28 +5180,59 @@ def s3_url_for_object(
) -> str
\`\`\`
-The S3 URL of an S3 object.
+The S3 URL of an S3 object. For example:.
-For example:
+\`s3://onlybucket\`
+- \`s3://bucket/key\`
-*Example*
+###### \`key\`Optional
+
+- *Type:* str
+
+The S3 key of the object.
+
+If not specified, the S3 URL of the
+bucket is returned.
+
+---
+
+##### \`transfer_acceleration_url_for_object\`
\`\`\`python
-s3://bucket/key
+def transfer_acceleration_url_for_object(
+ key: str = None,
+ dual_stack: bool = None
+) -> str
\`\`\`
+The https Transfer Acceleration URL of an S3 object.
-###### \`key\`Optional
+Specify \`dualStack: true\` at the options
+for dual-stack endpoint (connect to the bucket over IPv6). For example:
+
+- \`https://bucket.s3-accelerate.amazonaws.com\`
+- \`https://bucket.s3-accelerate.amazonaws.com/key\`
+
+###### \`key\`Optional
- *Type:* str
The S3 key of the object.
-If not specified, the S3 URL of the
+If not specified, the URL of the
bucket is returned.
---
+###### \`dual_stack\`Optional
+
+- *Type:* bool
+- *Default:* false
+
+Dual-stack support to connect to the bucket over IPv6.
+
+---
+
##### \`url_for_object\`
\`\`\`python
@@ -4894,17 +5241,11 @@ def url_for_object(
) -> str
\`\`\`
-The https URL of an S3 object.
-
-Specify \`regional: false\` at the options
-for non-regional URLs. For example:
-
-*Example*
-
-\`\`\`python
-https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey
-\`\`\`
+The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:.
+\`https://s3.us-west-1.amazonaws.com/onlybucket\`
+- \`https://s3.us-west-1.amazonaws.com/bucket/key\`
+- \`https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey\`
###### \`key\`Optional
@@ -4926,17 +5267,12 @@ def virtual_hosted_url_for_object(
) -> str
\`\`\`
-The virtual hosted-style URL of an S3 object.
-
-Specify \`regional: false\` at
-the options for non-regional URL. For example:
-
-*Example*
-
-\`\`\`python
-https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey
-\`\`\`
+The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:.
+\`https://only-bucket.s3.us-west-1.amazonaws.com\`
+- \`https://bucket.s3.us-west-1.amazonaws.com/key\`
+- \`https://bucket.s3.amazonaws.com/key\`
+- \`https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey\`
###### \`key\`Optional
@@ -5124,7 +5460,10 @@ def add_lifecycle_rule(
expired_object_delete_marker: bool = None,
id: str = None,
noncurrent_version_expiration: Duration = None,
+ noncurrent_versions_to_retain: typing.Union[int, float] = None,
noncurrent_version_transitions: typing.List[NoncurrentVersionTransition] = None,
+ object_size_greater_than: typing.Union[int, float] = None,
+ object_size_less_than: typing.Union[int, float] = None,
prefix: str = None,
tag_filters: typing.Mapping[typing.Any] = None,
transitions: typing.List[Transition] = None
@@ -5221,6 +5560,18 @@ transition time.
---
+###### \`noncurrent_versions_to_retain\`Optional
+
+- *Type:* typing.Union[int, float]
+- *Default:* No noncurrent versions to retain
+
+Indicates a maximum number of noncurrent versions to retain.
+
+If there are this many more noncurrent versions,
+Amazon S3 permanently deletes them.
+
+---
+
###### \`noncurrent_version_transitions\`Optional
- *Type:* typing.List[aws_cdk.aws_s3.NoncurrentVersionTransition]
@@ -5234,6 +5585,24 @@ must be later than the transition time.
---
+###### \`object_size_greater_than\`Optional
+
+- *Type:* typing.Union[int, float]
+- *Default:* No rule
+
+Specifies the minimum object size in bytes for this rule to apply to.
+
+---
+
+###### \`object_size_less_than\`Optional
+
+- *Type:* typing.Union[int, float]
+- *Default:* No rule
+
+Specifies the maximum object size in bytes for this rule to apply to.
+
+---
+
###### \`prefix\`Optional
- *Type:* str
@@ -5317,6 +5686,7 @@ def greet() -> None
| from_bucket_arn | *No description.* |
| from_bucket_attributes | Creates a Bucket construct that represents an external bucket. |
| from_bucket_name | *No description.* |
+| validate_bucket_name | Thrown an exception if the given bucket name is not valid. |
---
@@ -5386,6 +5756,7 @@ construct_library.GreeterBucket.from_bucket_attributes(
bucket_website_url: str = None,
encryption_key: IKey = None,
is_website: bool = None,
+ notifications_handler_role: IRole = None,
region: str = None
)
\`\`\`
@@ -5502,6 +5873,15 @@ If this bucket has been configured for static website hosting.
---
+###### \`notifications_handler_role\`Optional
+
+- *Type:* aws_cdk.aws_iam.IRole
+- *Default:* a new role will be created.
+
+The role to be used by the notifications handler.
+
+---
+
###### \`region\`Optional
- *Type:* str
@@ -5541,6 +5921,26 @@ construct_library.GreeterBucket.from_bucket_name(
---
+##### \`validate_bucket_name\`
+
+\`\`\`python
+import construct_library
+
+construct_library.GreeterBucket.validate_bucket_name(
+ physical_name: str
+)
+\`\`\`
+
+Thrown an exception if the given bucket name is not valid.
+
+###### \`physical_name\`Required
+
+- *Type:* str
+
+name of the bucket.
+
+---
+
#### Properties
| **Name** | **Type** | **Description** |
@@ -5783,7 +6183,7 @@ new GreeterBucket(scope: Construct, id: string, props?: BucketProps)
| addEventNotification | Adds a bucket notification event destination. |
| addObjectCreatedNotification | Subscribes a destination to receive notifications when an object is created in the bucket. |
| addObjectRemovedNotification | Subscribes a destination to receive notifications when an object is removed from the bucket. |
-| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
+| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
| arnForObjects | Returns an ARN that represents all objects within the bucket that match the key pattern specified. |
| grantDelete | Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket. |
| grantPublicAccess | Allows unrestricted access to objects from this bucket. |
@@ -5795,9 +6195,10 @@ new GreeterBucket(scope: Construct, id: string, props?: BucketProps)
| onCloudTrailEvent | Define a CloudWatch event that triggers when something happens to this repository. |
| onCloudTrailPutObject | Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call. |
| onCloudTrailWriteObject | Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to. |
-| s3UrlForObject | The S3 URL of an S3 object. |
-| urlForObject | The https URL of an S3 object. |
-| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. |
+| s3UrlForObject | The S3 URL of an S3 object. For example:. |
+| transferAccelerationUrlForObject | The https Transfer Acceleration URL of an S3 object. |
+| urlForObject | The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:. |
+| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:. |
| addCorsRule | Adds a cross-origin access configuration for objects in an Amazon S3 bucket. |
| addInventory | Add an inventory configuration. |
| addLifecycleRule | Add a lifecycle rule to the bucket. |
@@ -5819,7 +6220,7 @@ being managed by CloudFormation, either because you've removed it from the
CDK application or because you've made a change that requires the resource
to be replaced.
-The resource can be deleted (\`RemovalPolicy.DELETE\`), or left in your AWS
+The resource can be deleted (\`RemovalPolicy.DESTROY\`), or left in your AWS
account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
###### \`policy\`Required
@@ -5841,7 +6242,9 @@ Adds a bucket notification event destination.
*Example*
\`\`\`typescript
- bucket.addEventNotification(EventType.OnObjectCreated, myLambda, 'home/myusername/*')
+ declare const myLambda: lambda.Function;
+ const bucket = new s3.Bucket(this, 'MyBucket');
+ bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});
\`\`\`
@@ -5882,7 +6285,7 @@ public addObjectCreatedNotification(dest: IBucketNotificationDestination, filter
Subscribes a destination to receive notifications when an object is created in the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectCreated)\`.
+\`onEvent(EventType.OBJECT_CREATED)\`.
###### \`dest\`Required
@@ -5909,7 +6312,7 @@ public addObjectRemovedNotification(dest: IBucketNotificationDestination, filter
Subscribes a destination to receive notifications when an object is removed from the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectRemoved)\`.
+\`onEvent(EventType.OBJECT_REMOVED)\`.
###### \`dest\`Required
@@ -5933,12 +6336,20 @@ Filters (see onEvent).
public addToResourcePolicy(permission: PolicyStatement): AddToResourcePolicyResult
\`\`\`
-Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+
+Note that the policy statement may or may not be added to the policy.
+For example, when an \`IBucket\` is created from an existing bucket,
+it's not possible to tell whether the bucket already has a policy
+attached, let alone to re-use that policy to add more statements to it.
+So it's safest to do nothing in these cases.
###### \`permission\`Required
- *Type:* @aws-cdk/aws-iam.PolicyStatement
+the policy statement to be added to the bucket's policy.
+
---
##### \`arnForObjects\`
@@ -6008,6 +6419,10 @@ to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });
+Note that if this \`IBucket\` refers to an existing bucket, possibly not
+managed by CloudFormation, this method will have no effect, since it's
+impossible to modify the policy of an existing bucket.
+
###### \`allowedActions\`Required
- *Type:* string
@@ -6264,45 +6679,66 @@ Options for adding the rule.
public s3UrlForObject(key?: string): string
\`\`\`
-The S3 URL of an S3 object.
+The S3 URL of an S3 object. For example:.
-For example:
+\`s3://onlybucket\`
+- \`s3://bucket/key\`
-*Example*
+###### \`key\`Optional
+
+- *Type:* string
+
+The S3 key of the object.
+
+If not specified, the S3 URL of the
+bucket is returned.
+
+---
+
+##### \`transferAccelerationUrlForObject\`
\`\`\`typescript
-s3://bucket/key
+public transferAccelerationUrlForObject(key?: string, options?: TransferAccelerationUrlOptions): string
\`\`\`
+The https Transfer Acceleration URL of an S3 object.
-###### \`key\`Optional
+Specify \`dualStack: true\` at the options
+for dual-stack endpoint (connect to the bucket over IPv6). For example:
+
+- \`https://bucket.s3-accelerate.amazonaws.com\`
+- \`https://bucket.s3-accelerate.amazonaws.com/key\`
+
+###### \`key\`Optional
- *Type:* string
The S3 key of the object.
-If not specified, the S3 URL of the
+If not specified, the URL of the
bucket is returned.
---
-##### \`urlForObject\`
+###### \`options\`Optional
-\`\`\`typescript
-public urlForObject(key?: string): string
-\`\`\`
+- *Type:* @aws-cdk/aws-s3.TransferAccelerationUrlOptions
-The https URL of an S3 object.
+Options for generating URL.
-Specify \`regional: false\` at the options
-for non-regional URLs. For example:
+---
-*Example*
+##### \`urlForObject\`
\`\`\`typescript
-https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey
+public urlForObject(key?: string): string
\`\`\`
+The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:.
+
+\`https://s3.us-west-1.amazonaws.com/onlybucket\`
+- \`https://s3.us-west-1.amazonaws.com/bucket/key\`
+- \`https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey\`
###### \`key\`Optional
@@ -6321,17 +6757,12 @@ bucket is returned.
public virtualHostedUrlForObject(key?: string, options?: VirtualHostedStyleUrlOptions): string
\`\`\`
-The virtual hosted-style URL of an S3 object.
-
-Specify \`regional: false\` at
-the options for non-regional URL. For example:
-
-*Example*
-
-\`\`\`typescript
-https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey
-\`\`\`
+The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:.
+\`https://only-bucket.s3.us-west-1.amazonaws.com\`
+- \`https://bucket.s3.us-west-1.amazonaws.com/key\`
+- \`https://bucket.s3.amazonaws.com/key\`
+- \`https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey\`
###### \`key\`Optional
@@ -6430,6 +6861,7 @@ public greet(): void
| fromBucketArn | *No description.* |
| fromBucketAttributes | Creates a Bucket construct that represents an external bucket. |
| fromBucketName | *No description.* |
+| validateBucketName | Thrown an exception if the given bucket name is not valid. |
---
@@ -6538,6 +6970,24 @@ GreeterBucket.fromBucketName(scope: Construct, id: string, bucketName: string)
---
+##### \`validateBucketName\`
+
+\`\`\`typescript
+import { GreeterBucket } from 'construct-library'
+
+GreeterBucket.validateBucketName(physicalName: string)
+\`\`\`
+
+Thrown an exception if the given bucket name is not valid.
+
+###### \`physicalName\`Required
+
+- *Type:* string
+
+name of the bucket.
+
+---
+
#### Properties
| **Name** | **Type** | **Description** |
@@ -6780,7 +7230,7 @@ new submod1.GoodbyeBucket(scope: Construct, id: string, props?: BucketProps)
| addEventNotification | Adds a bucket notification event destination. |
| addObjectCreatedNotification | Subscribes a destination to receive notifications when an object is created in the bucket. |
| addObjectRemovedNotification | Subscribes a destination to receive notifications when an object is removed from the bucket. |
-| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
+| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
| arnForObjects | Returns an ARN that represents all objects within the bucket that match the key pattern specified. |
| grantDelete | Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket. |
| grantPublicAccess | Allows unrestricted access to objects from this bucket. |
@@ -6792,9 +7242,10 @@ new submod1.GoodbyeBucket(scope: Construct, id: string, props?: BucketProps)
| onCloudTrailEvent | Define a CloudWatch event that triggers when something happens to this repository. |
| onCloudTrailPutObject | Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call. |
| onCloudTrailWriteObject | Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to. |
-| s3UrlForObject | The S3 URL of an S3 object. |
-| urlForObject | The https URL of an S3 object. |
-| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. |
+| s3UrlForObject | The S3 URL of an S3 object. For example:. |
+| transferAccelerationUrlForObject | The https Transfer Acceleration URL of an S3 object. |
+| urlForObject | The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:. |
+| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:. |
| addCorsRule | Adds a cross-origin access configuration for objects in an Amazon S3 bucket. |
| addInventory | Add an inventory configuration. |
| addLifecycleRule | Add a lifecycle rule to the bucket. |
@@ -6816,7 +7267,7 @@ being managed by CloudFormation, either because you've removed it from the
CDK application or because you've made a change that requires the resource
to be replaced.
-The resource can be deleted (\`RemovalPolicy.DELETE\`), or left in your AWS
+The resource can be deleted (\`RemovalPolicy.DESTROY\`), or left in your AWS
account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
###### \`policy\`Required
@@ -6838,7 +7289,9 @@ Adds a bucket notification event destination.
*Example*
\`\`\`typescript
- bucket.addEventNotification(EventType.OnObjectCreated, myLambda, 'home/myusername/*')
+ declare const myLambda: lambda.Function;
+ const bucket = new s3.Bucket(this, 'MyBucket');
+ bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});
\`\`\`
@@ -6879,7 +7332,7 @@ public addObjectCreatedNotification(dest: IBucketNotificationDestination, filter
Subscribes a destination to receive notifications when an object is created in the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectCreated)\`.
+\`onEvent(EventType.OBJECT_CREATED)\`.
###### \`dest\`Required
@@ -6906,7 +7359,7 @@ public addObjectRemovedNotification(dest: IBucketNotificationDestination, filter
Subscribes a destination to receive notifications when an object is removed from the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectRemoved)\`.
+\`onEvent(EventType.OBJECT_REMOVED)\`.
###### \`dest\`Required
@@ -6930,12 +7383,20 @@ Filters (see onEvent).
public addToResourcePolicy(permission: PolicyStatement): AddToResourcePolicyResult
\`\`\`
-Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+
+Note that the policy statement may or may not be added to the policy.
+For example, when an \`IBucket\` is created from an existing bucket,
+it's not possible to tell whether the bucket already has a policy
+attached, let alone to re-use that policy to add more statements to it.
+So it's safest to do nothing in these cases.
###### \`permission\`Required
- *Type:* @aws-cdk/aws-iam.PolicyStatement
+the policy statement to be added to the bucket's policy.
+
---
##### \`arnForObjects\`
@@ -7005,6 +7466,10 @@ to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });
+Note that if this \`IBucket\` refers to an existing bucket, possibly not
+managed by CloudFormation, this method will have no effect, since it's
+impossible to modify the policy of an existing bucket.
+
###### \`allowedActions\`Required
- *Type:* string
@@ -7261,45 +7726,66 @@ Options for adding the rule.
public s3UrlForObject(key?: string): string
\`\`\`
-The S3 URL of an S3 object.
+The S3 URL of an S3 object. For example:.
-For example:
+\`s3://onlybucket\`
+- \`s3://bucket/key\`
-*Example*
+###### \`key\`Optional
+
+- *Type:* string
+
+The S3 key of the object.
+
+If not specified, the S3 URL of the
+bucket is returned.
+
+---
+
+##### \`transferAccelerationUrlForObject\`
\`\`\`typescript
-s3://bucket/key
+public transferAccelerationUrlForObject(key?: string, options?: TransferAccelerationUrlOptions): string
\`\`\`
+The https Transfer Acceleration URL of an S3 object.
-###### \`key\`Optional
+Specify \`dualStack: true\` at the options
+for dual-stack endpoint (connect to the bucket over IPv6). For example:
+
+- \`https://bucket.s3-accelerate.amazonaws.com\`
+- \`https://bucket.s3-accelerate.amazonaws.com/key\`
+
+###### \`key\`Optional
- *Type:* string
The S3 key of the object.
-If not specified, the S3 URL of the
+If not specified, the URL of the
bucket is returned.
---
-##### \`urlForObject\`
+###### \`options\`Optional
-\`\`\`typescript
-public urlForObject(key?: string): string
-\`\`\`
+- *Type:* @aws-cdk/aws-s3.TransferAccelerationUrlOptions
-The https URL of an S3 object.
+Options for generating URL.
-Specify \`regional: false\` at the options
-for non-regional URLs. For example:
+---
-*Example*
+##### \`urlForObject\`
\`\`\`typescript
-https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey
+public urlForObject(key?: string): string
\`\`\`
+The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:.
+
+\`https://s3.us-west-1.amazonaws.com/onlybucket\`
+- \`https://s3.us-west-1.amazonaws.com/bucket/key\`
+- \`https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey\`
###### \`key\`Optional
@@ -7318,17 +7804,12 @@ bucket is returned.
public virtualHostedUrlForObject(key?: string, options?: VirtualHostedStyleUrlOptions): string
\`\`\`
-The virtual hosted-style URL of an S3 object.
-
-Specify \`regional: false\` at
-the options for non-regional URL. For example:
-
-*Example*
-
-\`\`\`typescript
-https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey
-\`\`\`
+The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:.
+\`https://only-bucket.s3.us-west-1.amazonaws.com\`
+- \`https://bucket.s3.us-west-1.amazonaws.com/key\`
+- \`https://bucket.s3.amazonaws.com/key\`
+- \`https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey\`
###### \`key\`Optional
@@ -7427,6 +7908,7 @@ public goodbye(): void
| fromBucketArn | *No description.* |
| fromBucketAttributes | Creates a Bucket construct that represents an external bucket. |
| fromBucketName | *No description.* |
+| validateBucketName | Thrown an exception if the given bucket name is not valid. |
---
@@ -7535,6 +8017,24 @@ submod1.GoodbyeBucket.fromBucketName(scope: Construct, id: string, bucketName: s
---
+##### \`validateBucketName\`
+
+\`\`\`typescript
+import { submod1 } from 'construct-library'
+
+submod1.GoodbyeBucket.validateBucketName(physicalName: string)
+\`\`\`
+
+Thrown an exception if the given bucket name is not valid.
+
+###### \`physicalName\`Required
+
+- *Type:* string
+
+name of the bucket.
+
+---
+
#### Properties
| **Name** | **Type** | **Description** |
diff --git a/apps/jsii-docgen/test/docgen/view/__snapshots__/documentation.test.ts.snap b/apps/jsii-docgen/test/docgen/view/__snapshots__/documentation.test.ts.snap
index 1d020625cea..26504ef1ef9 100644
--- a/apps/jsii-docgen/test/docgen/view/__snapshots__/documentation.test.ts.snap
+++ b/apps/jsii-docgen/test/docgen/view/__snapshots__/documentation.test.ts.snap
@@ -51,7 +51,7 @@ being managed by CloudFormation, either because you've removed it from the
CDK application or because you've made a change that requires the resource
to be replaced.
-The resource can be deleted (\`RemovalPolicy.DELETE\`), or left in your AWS
+The resource can be deleted (\`RemovalPolicy.DESTROY\`), or left in your AWS
account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).",
"summary": "Apply the given removal policy to this resource.",
},
@@ -84,7 +84,9 @@ account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).",
Object {
"displayName": "addEventNotification",
"docs": Object {
- "example": " bucket.addEventNotification(EventType.OnObjectCreated, myLambda, 'home/myusername/*')",
+ "example": " declare const myLambda: lambda.Function;
+ const bucket = new s3.Bucket(this, 'MyBucket');
+ bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});",
"links": Array [
"https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html",
],
@@ -163,13 +165,13 @@ for details about allowed filter rules.",
},
},
],
- "usage": "addEventNotification(event: EventType, dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void",
+ "usage": "addEventNotification(event: EventType, dest: IBucketNotificationDestination, ...filters: Array): void",
},
Object {
"displayName": "addObjectCreatedNotification",
"docs": Object {
"remarks": "This is identical to calling
-\`onEvent(EventType.ObjectCreated)\`.",
+\`onEvent(EventType.OBJECT_CREATED)\`.",
"summary": "Subscribes a destination to receive notifications when an object is created in the bucket.",
},
"fqn": "construct-library.GreeterBucket.addObjectCreatedNotification",
@@ -220,13 +222,13 @@ for details about allowed filter rules.",
},
},
],
- "usage": "addObjectCreatedNotification(dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void",
+ "usage": "addObjectCreatedNotification(dest: IBucketNotificationDestination, ...filters: Array): void",
},
Object {
"displayName": "addObjectRemovedNotification",
"docs": Object {
"remarks": "This is identical to calling
-\`onEvent(EventType.ObjectRemoved)\`.",
+\`onEvent(EventType.OBJECT_REMOVED)\`.",
"summary": "Subscribes a destination to receive notifications when an object is removed from the bucket.",
},
"fqn": "construct-library.GreeterBucket.addObjectRemovedNotification",
@@ -277,12 +279,17 @@ for details about allowed filter rules.",
},
},
],
- "usage": "addObjectRemovedNotification(dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void",
+ "usage": "addObjectRemovedNotification(dest: IBucketNotificationDestination, ...filters: Array): void",
},
Object {
"displayName": "addToResourcePolicy",
"docs": Object {
- "summary": "Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.",
+ "remarks": "Note that the policy statement may or may not be added to the policy.
+For example, when an \`IBucket\` is created from an existing bucket,
+it's not possible to tell whether the bucket already has a policy
+attached, let alone to re-use that policy to add more statements to it.
+So it's safest to do nothing in these cases.",
+ "summary": "Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.",
},
"fqn": "construct-library.GreeterBucket.addToResourcePolicy",
"id": "construct-library.GreeterBucket.addToResourcePolicy",
@@ -290,7 +297,9 @@ for details about allowed filter rules.",
Object {
"default": undefined,
"displayName": "permission",
- "docs": Object {},
+ "docs": Object {
+ "summary": "the policy statement to be added to the bucket's policy.",
+ },
"fqn": "construct-library.GreeterBucket.addToResourcePolicy.parameter.permission",
"id": "construct-library.GreeterBucket.addToResourcePolicy.parameter.permission",
"optional": undefined,
@@ -399,7 +408,11 @@ as needed. For example, you can add a condition that will restrict access only
to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
- grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });",
+ grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });
+
+Note that if this \`IBucket\` refers to an existing bucket, possibly not
+managed by CloudFormation, this method will have no effect, since it's
+impossible to modify the policy of an existing bucket.",
"summary": "Allows unrestricted access to objects from this bucket.",
},
"fqn": "construct-library.GreeterBucket.grantPublicAccess",
@@ -433,7 +446,7 @@ to an IPv4 range like this:
},
},
],
- "usage": "grantPublicAccess(allowedActions: str, keyPrefix?: str): Grant",
+ "usage": "grantPublicAccess(...allowedActions: Array, keyPrefix?: str): Grant",
},
Object {
"displayName": "grantPut",
@@ -799,9 +812,9 @@ that captures the event. This method will not create the Trail.",
Object {
"displayName": "s3UrlForObject",
"docs": Object {
- "example": "s3://bucket/key",
- "remarks": "For example:",
- "summary": "The S3 URL of an S3 object.",
+ "remarks": "- \`s3://onlybucket\`
+- \`s3://bucket/key\`",
+ "summary": "The S3 URL of an S3 object. For example:.",
},
"fqn": "construct-library.GreeterBucket.s3UrlForObject",
"id": "construct-library.GreeterBucket.s3UrlForObject",
@@ -824,13 +837,66 @@ bucket is returned.",
],
"usage": "s3UrlForObject(key?: str): str",
},
+ Object {
+ "displayName": "transferAccelerationUrlForObject",
+ "docs": Object {
+ "remarks": "Specify \`dualStack: true\` at the options
+for dual-stack endpoint (connect to the bucket over IPv6). For example:
+
+- \`https://bucket.s3-accelerate.amazonaws.com\`
+- \`https://bucket.s3-accelerate.amazonaws.com/key\`",
+ "summary": "The https Transfer Acceleration URL of an S3 object.",
+ },
+ "fqn": "construct-library.GreeterBucket.transferAccelerationUrlForObject",
+ "id": "construct-library.GreeterBucket.transferAccelerationUrlForObject",
+ "parameters": Array [
+ Object {
+ "default": undefined,
+ "displayName": "key",
+ "docs": Object {
+ "remarks": "If not specified, the URL of the
+bucket is returned.",
+ "summary": "The S3 key of the object.",
+ },
+ "fqn": "construct-library.GreeterBucket.transferAccelerationUrlForObject.parameter.key",
+ "id": "construct-library.GreeterBucket.transferAccelerationUrlForObject.parameter.key",
+ "optional": true,
+ "type": Object {
+ "formattingPattern": "str",
+ },
+ },
+ Object {
+ "default": undefined,
+ "displayName": "options",
+ "docs": Object {
+ "summary": "Options for generating URL.",
+ },
+ "fqn": "construct-library.GreeterBucket.transferAccelerationUrlForObject.parameter.options",
+ "id": "construct-library.GreeterBucket.transferAccelerationUrlForObject.parameter.options",
+ "optional": true,
+ "type": Object {
+ "formattingPattern": "%",
+ "types": Array [
+ Object {
+ "displayName": "TransferAccelerationUrlOptions",
+ "fqn": "@aws-cdk/aws-s3.TransferAccelerationUrlOptions",
+ "id": "@aws-cdk/aws-s3.TransferAccelerationUrlOptions",
+ "packageName": "@aws-cdk/aws-s3",
+ "packageVersion": "99.99.99",
+ },
+ ],
+ },
+ },
+ ],
+ "usage": "transferAccelerationUrlForObject(key?: str, options?: TransferAccelerationUrlOptions): str",
+ },
Object {
"displayName": "urlForObject",
"docs": Object {
- "example": "https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey",
- "remarks": "Specify \`regional: false\` at the options
-for non-regional URLs. For example:",
- "summary": "The https URL of an S3 object.",
+ "remarks": "- \`https://s3.us-west-1.amazonaws.com/onlybucket\`
+- \`https://s3.us-west-1.amazonaws.com/bucket/key\`
+- \`https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey\`",
+ "summary": "The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:.",
},
"fqn": "construct-library.GreeterBucket.urlForObject",
"id": "construct-library.GreeterBucket.urlForObject",
@@ -856,10 +922,11 @@ bucket is returned.",
Object {
"displayName": "virtualHostedUrlForObject",
"docs": Object {
- "example": "https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey",
- "remarks": "Specify \`regional: false\` at
-the options for non-regional URL. For example:",
- "summary": "The virtual hosted-style URL of an S3 object.",
+ "remarks": "- \`https://only-bucket.s3.us-west-1.amazonaws.com\`
+- \`https://bucket.s3.us-west-1.amazonaws.com/key\`
+- \`https://bucket.s3.amazonaws.com/key\`
+- \`https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey\`",
+ "summary": "The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:.",
},
"fqn": "construct-library.GreeterBucket.virtualHostedUrlForObject",
"id": "construct-library.GreeterBucket.virtualHostedUrlForObject",
@@ -1398,6 +1465,32 @@ GreeterBucket.fromBucketAttributes(attrs: BucketAttributes);",
GreeterBucket.fromBucketName(bucketName: str);",
},
+ Object {
+ "displayName": "validateBucketName",
+ "docs": Object {
+ "summary": "Thrown an exception if the given bucket name is not valid.",
+ },
+ "fqn": "construct-library.GreeterBucket.validateBucketName",
+ "id": "construct-library.GreeterBucket.validateBucketName",
+ "parameters": Array [
+ Object {
+ "default": undefined,
+ "displayName": "physicalName",
+ "docs": Object {
+ "summary": "name of the bucket.",
+ },
+ "fqn": "construct-library.GreeterBucket.validateBucketName.parameter.physicalName",
+ "id": "construct-library.GreeterBucket.validateBucketName.parameter.physicalName",
+ "optional": undefined,
+ "type": Object {
+ "formattingPattern": "str",
+ },
+ },
+ ],
+ "usage": "bring { GreeterBucket } from \\"construct-library\\";
+
+GreeterBucket.validateBucketName(physicalName: str);",
+ },
],
},
],
@@ -1458,7 +1551,7 @@ new GreeterBucket(props?: BucketProps);
| addEventNotification | Adds a bucket notification event destination. |
| addObjectCreatedNotification | Subscribes a destination to receive notifications when an object is created in the bucket. |
| addObjectRemovedNotification | Subscribes a destination to receive notifications when an object is removed from the bucket. |
-| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
+| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
| arnForObjects | Returns an ARN that represents all objects within the bucket that match the key pattern specified. |
| grantDelete | Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket. |
| grantPublicAccess | Allows unrestricted access to objects from this bucket. |
@@ -1470,9 +1563,10 @@ new GreeterBucket(props?: BucketProps);
| onCloudTrailEvent | Define a CloudWatch event that triggers when something happens to this repository. |
| onCloudTrailPutObject | Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call. |
| onCloudTrailWriteObject | Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to. |
-| s3UrlForObject | The S3 URL of an S3 object. |
-| urlForObject | The https URL of an S3 object. |
-| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. |
+| s3UrlForObject | The S3 URL of an S3 object. For example:. |
+| transferAccelerationUrlForObject | The https Transfer Acceleration URL of an S3 object. |
+| urlForObject | The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:. |
+| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:. |
| addCorsRule | Adds a cross-origin access configuration for objects in an Amazon S3 bucket. |
| addInventory | Add an inventory configuration. |
| addLifecycleRule | Add a lifecycle rule to the bucket. |
@@ -1494,7 +1588,7 @@ being managed by CloudFormation, either because you've removed it from the
CDK application or because you've made a change that requires the resource
to be replaced.
-The resource can be deleted (\`RemovalPolicy.DELETE\`), or left in your AWS
+The resource can be deleted (\`RemovalPolicy.DESTROY\`), or left in your AWS
account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
###### \`policy\`Required
@@ -1506,7 +1600,7 @@ account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
##### \`addEventNotification\`
\`\`\`wing
-addEventNotification(event: EventType, dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void
+addEventNotification(event: EventType, dest: IBucketNotificationDestination, ...filters: Array): void
\`\`\`
Adds a bucket notification event destination.
@@ -1516,7 +1610,9 @@ Adds a bucket notification event destination.
*Example*
\`\`\`wing
- bucket.addEventNotification(EventType.OnObjectCreated, myLambda, 'home/myusername/*')
+ declare const myLambda: lambda.Function;
+ const bucket = new s3.Bucket(this, 'MyBucket');
+ bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});
\`\`\`
@@ -1551,13 +1647,13 @@ for details about allowed filter rules.
##### \`addObjectCreatedNotification\`
\`\`\`wing
-addObjectCreatedNotification(dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void
+addObjectCreatedNotification(dest: IBucketNotificationDestination, ...filters: Array): void
\`\`\`
Subscribes a destination to receive notifications when an object is created in the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectCreated)\`.
+\`onEvent(EventType.OBJECT_CREATED)\`.
###### \`dest\`Required
@@ -1578,13 +1674,13 @@ Filters (see onEvent).
##### \`addObjectRemovedNotification\`
\`\`\`wing
-addObjectRemovedNotification(dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void
+addObjectRemovedNotification(dest: IBucketNotificationDestination, ...filters: Array): void
\`\`\`
Subscribes a destination to receive notifications when an object is removed from the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectRemoved)\`.
+\`onEvent(EventType.OBJECT_REMOVED)\`.
###### \`dest\`Required
@@ -1608,12 +1704,20 @@ Filters (see onEvent).
addToResourcePolicy(permission: PolicyStatement): AddToResourcePolicyResult
\`\`\`
-Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+
+Note that the policy statement may or may not be added to the policy.
+For example, when an \`IBucket\` is created from an existing bucket,
+it's not possible to tell whether the bucket already has a policy
+attached, let alone to re-use that policy to add more statements to it.
+So it's safest to do nothing in these cases.
###### \`permission\`Required
- *Type:* @aws-cdk/aws-iam.PolicyStatement
+the policy statement to be added to the bucket's policy.
+
---
##### \`arnForObjects\`
@@ -1663,7 +1767,7 @@ Restrict the permission to a certain key pattern (default '*').
##### \`grantPublicAccess\`
\`\`\`wing
-grantPublicAccess(allowedActions: str, keyPrefix?: str): Grant
+grantPublicAccess(...allowedActions: Array, keyPrefix?: str): Grant
\`\`\`
Allows unrestricted access to objects from this bucket.
@@ -1683,6 +1787,10 @@ to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });
+Note that if this \`IBucket\` refers to an existing bucket, possibly not
+managed by CloudFormation, this method will have no effect, since it's
+impossible to modify the policy of an existing bucket.
+
###### \`allowedActions\`Required
- *Type:* str
@@ -1915,45 +2023,66 @@ Options for adding the rule.
s3UrlForObject(key?: str): str
\`\`\`
-The S3 URL of an S3 object.
+The S3 URL of an S3 object. For example:.
-For example:
+\`s3://onlybucket\`
+- \`s3://bucket/key\`
-*Example*
+###### \`key\`Optional
+
+- *Type:* str
+
+The S3 key of the object.
+
+If not specified, the S3 URL of the
+bucket is returned.
+
+---
+
+##### \`transferAccelerationUrlForObject\`
\`\`\`wing
-s3://bucket/key
+transferAccelerationUrlForObject(key?: str, options?: TransferAccelerationUrlOptions): str
\`\`\`
+The https Transfer Acceleration URL of an S3 object.
-###### \`key\`Optional
+Specify \`dualStack: true\` at the options
+for dual-stack endpoint (connect to the bucket over IPv6). For example:
+
+- \`https://bucket.s3-accelerate.amazonaws.com\`
+- \`https://bucket.s3-accelerate.amazonaws.com/key\`
+
+###### \`key\`Optional
- *Type:* str
The S3 key of the object.
-If not specified, the S3 URL of the
+If not specified, the URL of the
bucket is returned.
---
-##### \`urlForObject\`
+###### \`options\`Optional
-\`\`\`wing
-urlForObject(key?: str): str
-\`\`\`
+- *Type:* @aws-cdk/aws-s3.TransferAccelerationUrlOptions
-The https URL of an S3 object.
+Options for generating URL.
-Specify \`regional: false\` at the options
-for non-regional URLs. For example:
+---
-*Example*
+##### \`urlForObject\`
\`\`\`wing
-https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey
+urlForObject(key?: str): str
\`\`\`
+The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:.
+
+\`https://s3.us-west-1.amazonaws.com/onlybucket\`
+- \`https://s3.us-west-1.amazonaws.com/bucket/key\`
+- \`https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey\`
###### \`key\`Optional
@@ -1972,17 +2101,12 @@ bucket is returned.
virtualHostedUrlForObject(key?: str, options?: VirtualHostedStyleUrlOptions): str
\`\`\`
-The virtual hosted-style URL of an S3 object.
-
-Specify \`regional: false\` at
-the options for non-regional URL. For example:
-
-*Example*
-
-\`\`\`wing
-https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey
-\`\`\`
+The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:.
+\`https://only-bucket.s3.us-west-1.amazonaws.com\`
+- \`https://bucket.s3.us-west-1.amazonaws.com/key\`
+- \`https://bucket.s3.amazonaws.com/key\`
+- \`https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey\`
###### \`key\`Optional
@@ -2081,6 +2205,7 @@ greet(): void
| fromBucketArn | *No description.* |
| fromBucketAttributes | Creates a Bucket construct that represents an external bucket. |
| fromBucketName | *No description.* |
+| validateBucketName | Thrown an exception if the given bucket name is not valid. |
---
@@ -2149,6 +2274,24 @@ GreeterBucket.fromBucketName(bucketName: str);
---
+##### \`validateBucketName\`
+
+\`\`\`wing
+bring { GreeterBucket } from \\"construct-library\\";
+
+GreeterBucket.validateBucketName(physicalName: str);
+\`\`\`
+
+Thrown an exception if the given bucket name is not valid.
+
+###### \`physicalName\`Required
+
+- *Type:* str
+
+name of the bucket.
+
+---
+
#### Properties
| **Name** | **Type** | **Description** |
diff --git a/apps/jsii-docgen/test/docgen/view/__snapshots__/interface.test.ts.snap b/apps/jsii-docgen/test/docgen/view/__snapshots__/interface.test.ts.snap
index 7a2cf8b6937..8792e6cd812 100644
--- a/apps/jsii-docgen/test/docgen/view/__snapshots__/interface.test.ts.snap
+++ b/apps/jsii-docgen/test/docgen/view/__snapshots__/interface.test.ts.snap
@@ -4886,7 +4886,7 @@ Object {
},
},
],
- "usage": "grant(grantee: IGrantable, actions: str): Grant",
+ "usage": "grant(grantee: IGrantable, ...actions: Array): Grant",
},
Object {
"displayName": "grantPull",
@@ -5312,7 +5312,7 @@ Add a policy statement to the repository's resource policy.
## \`grant\`
\`\`\`wing
-grant(grantee: IGrantable, actions: str): Grant
+grant(grantee: IGrantable, ...actions: Array): Grant
\`\`\`
Grant the given principal identity permissions to perform the actions on this repository.
diff --git a/apps/jsii-docgen/test/docgen/view/__snapshots__/markdown.test.ts.snap b/apps/jsii-docgen/test/docgen/view/__snapshots__/markdown.test.ts.snap
index 9790618904f..6721cd97140 100644
--- a/apps/jsii-docgen/test/docgen/view/__snapshots__/markdown.test.ts.snap
+++ b/apps/jsii-docgen/test/docgen/view/__snapshots__/markdown.test.ts.snap
@@ -39,7 +39,7 @@ new GreeterBucket(props?: BucketProps);
| addEventNotification | Adds a bucket notification event destination. |
| addObjectCreatedNotification | Subscribes a destination to receive notifications when an object is created in the bucket. |
| addObjectRemovedNotification | Subscribes a destination to receive notifications when an object is removed from the bucket. |
-| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
+| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
| arnForObjects | Returns an ARN that represents all objects within the bucket that match the key pattern specified. |
| grantDelete | Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket. |
| grantPublicAccess | Allows unrestricted access to objects from this bucket. |
@@ -51,9 +51,10 @@ new GreeterBucket(props?: BucketProps);
| onCloudTrailEvent | Define a CloudWatch event that triggers when something happens to this repository. |
| onCloudTrailPutObject | Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call. |
| onCloudTrailWriteObject | Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to. |
-| s3UrlForObject | The S3 URL of an S3 object. |
-| urlForObject | The https URL of an S3 object. |
-| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. |
+| s3UrlForObject | The S3 URL of an S3 object. For example:. |
+| transferAccelerationUrlForObject | The https Transfer Acceleration URL of an S3 object. |
+| urlForObject | The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:. |
+| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:. |
| addCorsRule | Adds a cross-origin access configuration for objects in an Amazon S3 bucket. |
| addInventory | Add an inventory configuration. |
| addLifecycleRule | Add a lifecycle rule to the bucket. |
@@ -75,7 +76,7 @@ being managed by CloudFormation, either because you've removed it from the
CDK application or because you've made a change that requires the resource
to be replaced.
-The resource can be deleted (\`RemovalPolicy.DELETE\`), or left in your AWS
+The resource can be deleted (\`RemovalPolicy.DESTROY\`), or left in your AWS
account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
###### \`policy\`Required
@@ -87,7 +88,7 @@ account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
##### \`addEventNotification\`
\`\`\`wing
-addEventNotification(event: EventType, dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void
+addEventNotification(event: EventType, dest: IBucketNotificationDestination, ...filters: Array): void
\`\`\`
Adds a bucket notification event destination.
@@ -97,7 +98,9 @@ Adds a bucket notification event destination.
*Example*
\`\`\`wing
- bucket.addEventNotification(EventType.OnObjectCreated, myLambda, 'home/myusername/*')
+ declare const myLambda: lambda.Function;
+ const bucket = new s3.Bucket(this, 'MyBucket');
+ bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});
\`\`\`
@@ -132,13 +135,13 @@ for details about allowed filter rules.
##### \`addObjectCreatedNotification\`
\`\`\`wing
-addObjectCreatedNotification(dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void
+addObjectCreatedNotification(dest: IBucketNotificationDestination, ...filters: Array): void
\`\`\`
Subscribes a destination to receive notifications when an object is created in the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectCreated)\`.
+\`onEvent(EventType.OBJECT_CREATED)\`.
###### \`dest\`Required
@@ -159,13 +162,13 @@ Filters (see onEvent).
##### \`addObjectRemovedNotification\`
\`\`\`wing
-addObjectRemovedNotification(dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void
+addObjectRemovedNotification(dest: IBucketNotificationDestination, ...filters: Array): void
\`\`\`
Subscribes a destination to receive notifications when an object is removed from the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectRemoved)\`.
+\`onEvent(EventType.OBJECT_REMOVED)\`.
###### \`dest\`Required
@@ -189,12 +192,20 @@ Filters (see onEvent).
addToResourcePolicy(permission: PolicyStatement): AddToResourcePolicyResult
\`\`\`
-Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+
+Note that the policy statement may or may not be added to the policy.
+For example, when an \`IBucket\` is created from an existing bucket,
+it's not possible to tell whether the bucket already has a policy
+attached, let alone to re-use that policy to add more statements to it.
+So it's safest to do nothing in these cases.
###### \`permission\`Required
- *Type:* PolicyStatement
+the policy statement to be added to the bucket's policy.
+
---
##### \`arnForObjects\`
@@ -244,7 +255,7 @@ Restrict the permission to a certain key pattern (default '*').
##### \`grantPublicAccess\`
\`\`\`wing
-grantPublicAccess(allowedActions: str, keyPrefix?: str): Grant
+grantPublicAccess(...allowedActions: Array, keyPrefix?: str): Grant
\`\`\`
Allows unrestricted access to objects from this bucket.
@@ -264,6 +275,10 @@ to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });
+Note that if this \`IBucket\` refers to an existing bucket, possibly not
+managed by CloudFormation, this method will have no effect, since it's
+impossible to modify the policy of an existing bucket.
+
###### \`allowedActions\`Required
- *Type:* str
@@ -496,45 +511,66 @@ Options for adding the rule.
s3UrlForObject(key?: str): str
\`\`\`
-The S3 URL of an S3 object.
+The S3 URL of an S3 object. For example:.
-For example:
+\`s3://onlybucket\`
+- \`s3://bucket/key\`
-*Example*
+###### \`key\`Optional
+
+- *Type:* str
+
+The S3 key of the object.
+
+If not specified, the S3 URL of the
+bucket is returned.
+
+---
+
+##### \`transferAccelerationUrlForObject\`
\`\`\`wing
-s3://bucket/key
+transferAccelerationUrlForObject(key?: str, options?: TransferAccelerationUrlOptions): str
\`\`\`
+The https Transfer Acceleration URL of an S3 object.
-###### \`key\`Optional
+Specify \`dualStack: true\` at the options
+for dual-stack endpoint (connect to the bucket over IPv6). For example:
+
+- \`https://bucket.s3-accelerate.amazonaws.com\`
+- \`https://bucket.s3-accelerate.amazonaws.com/key\`
+
+###### \`key\`Optional
- *Type:* str
The S3 key of the object.
-If not specified, the S3 URL of the
+If not specified, the URL of the
bucket is returned.
---
-##### \`urlForObject\`
+###### \`options\`Optional
-\`\`\`wing
-urlForObject(key?: str): str
-\`\`\`
+- *Type:* TransferAccelerationUrlOptions
-The https URL of an S3 object.
+Options for generating URL.
-Specify \`regional: false\` at the options
-for non-regional URLs. For example:
+---
-*Example*
+##### \`urlForObject\`
\`\`\`wing
-https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey
+urlForObject(key?: str): str
\`\`\`
+The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:.
+
+\`https://s3.us-west-1.amazonaws.com/onlybucket\`
+- \`https://s3.us-west-1.amazonaws.com/bucket/key\`
+- \`https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey\`
###### \`key\`Optional
@@ -553,17 +589,12 @@ bucket is returned.
virtualHostedUrlForObject(key?: str, options?: VirtualHostedStyleUrlOptions): str
\`\`\`
-The virtual hosted-style URL of an S3 object.
-
-Specify \`regional: false\` at
-the options for non-regional URL. For example:
-
-*Example*
-
-\`\`\`wing
-https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey
-\`\`\`
+The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:.
+\`https://only-bucket.s3.us-west-1.amazonaws.com\`
+- \`https://bucket.s3.us-west-1.amazonaws.com/key\`
+- \`https://bucket.s3.amazonaws.com/key\`
+- \`https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey\`
###### \`key\`Optional
@@ -662,6 +693,7 @@ greet(): void
| fromBucketArn | *No description.* |
| fromBucketAttributes | Creates a Bucket construct that represents an external bucket. |
| fromBucketName | *No description.* |
+| validateBucketName | Thrown an exception if the given bucket name is not valid. |
---
@@ -730,6 +762,24 @@ GreeterBucket.fromBucketName(bucketName: str);
---
+##### \`validateBucketName\`
+
+\`\`\`wing
+bring { GreeterBucket } from \\"construct-library\\";
+
+GreeterBucket.validateBucketName(physicalName: str);
+\`\`\`
+
+Thrown an exception if the given bucket name is not valid.
+
+###### \`physicalName\`Required
+
+- *Type:* str
+
+name of the bucket.
+
+---
+
#### Properties
| **Name** | **Type** | **Description** |
@@ -962,7 +1012,7 @@ new GreeterBucket(props?: BucketProps);
| addEventNotification | Adds a bucket notification event destination. |
| addObjectCreatedNotification | Subscribes a destination to receive notifications when an object is created in the bucket. |
| addObjectRemovedNotification | Subscribes a destination to receive notifications when an object is removed from the bucket. |
-| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
+| addToResourcePolicy | Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects. |
| arnForObjects | Returns an ARN that represents all objects within the bucket that match the key pattern specified. |
| grantDelete | Grants s3:DeleteObject* permission to an IAM principal for objects in this bucket. |
| grantPublicAccess | Allows unrestricted access to objects from this bucket. |
@@ -974,9 +1024,10 @@ new GreeterBucket(props?: BucketProps);
| onCloudTrailEvent | Define a CloudWatch event that triggers when something happens to this repository. |
| onCloudTrailPutObject | Defines an AWS CloudWatch event that triggers when an object is uploaded to the specified paths (keys) in this bucket using the PutObject API call. |
| onCloudTrailWriteObject | Defines an AWS CloudWatch event that triggers when an object at the specified paths (keys) in this bucket are written to. |
-| s3UrlForObject | The S3 URL of an S3 object. |
-| urlForObject | The https URL of an S3 object. |
-| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. |
+| s3UrlForObject | The S3 URL of an S3 object. For example:. |
+| transferAccelerationUrlForObject | The https Transfer Acceleration URL of an S3 object. |
+| urlForObject | The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:. |
+| virtualHostedUrlForObject | The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:. |
| addCorsRule | Adds a cross-origin access configuration for objects in an Amazon S3 bucket. |
| addInventory | Add an inventory configuration. |
| addLifecycleRule | Add a lifecycle rule to the bucket. |
@@ -998,7 +1049,7 @@ being managed by CloudFormation, either because you've removed it from the
CDK application or because you've made a change that requires the resource
to be replaced.
-The resource can be deleted (\`RemovalPolicy.DELETE\`), or left in your AWS
+The resource can be deleted (\`RemovalPolicy.DESTROY\`), or left in your AWS
account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
###### \`policy\`Required
@@ -1010,7 +1061,7 @@ account for data recovery and cleanup later (\`RemovalPolicy.RETAIN\`).
##### \`addEventNotification\`
\`\`\`wing
-addEventNotification(event: EventType, dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void
+addEventNotification(event: EventType, dest: IBucketNotificationDestination, ...filters: Array): void
\`\`\`
Adds a bucket notification event destination.
@@ -1020,7 +1071,9 @@ Adds a bucket notification event destination.
*Example*
\`\`\`wing
- bucket.addEventNotification(EventType.OnObjectCreated, myLambda, 'home/myusername/*')
+ declare const myLambda: lambda.Function;
+ const bucket = new s3.Bucket(this, 'MyBucket');
+ bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(myLambda), {prefix: 'home/myusername/*'});
\`\`\`
@@ -1055,13 +1108,13 @@ for details about allowed filter rules.
##### \`addObjectCreatedNotification\`
\`\`\`wing
-addObjectCreatedNotification(dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void
+addObjectCreatedNotification(dest: IBucketNotificationDestination, ...filters: Array): void
\`\`\`
Subscribes a destination to receive notifications when an object is created in the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectCreated)\`.
+\`onEvent(EventType.OBJECT_CREATED)\`.
###### \`dest\`Required
@@ -1082,13 +1135,13 @@ Filters (see onEvent).
##### \`addObjectRemovedNotification\`
\`\`\`wing
-addObjectRemovedNotification(dest: IBucketNotificationDestination, filters: NotificationKeyFilter): void
+addObjectRemovedNotification(dest: IBucketNotificationDestination, ...filters: Array): void
\`\`\`
Subscribes a destination to receive notifications when an object is removed from the bucket.
This is identical to calling
-\`onEvent(EventType.ObjectRemoved)\`.
+\`onEvent(EventType.OBJECT_REMOVED)\`.
###### \`dest\`Required
@@ -1112,12 +1165,20 @@ Filters (see onEvent).
addToResourcePolicy(permission: PolicyStatement): AddToResourcePolicyResult
\`\`\`
-Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or it's contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+Adds a statement to the resource policy for a principal (i.e. account/role/service) to perform actions on this bucket and/or its contents. Use \`bucketArn\` and \`arnForObjects(keys)\` to obtain ARNs for this bucket or objects.
+
+Note that the policy statement may or may not be added to the policy.
+For example, when an \`IBucket\` is created from an existing bucket,
+it's not possible to tell whether the bucket already has a policy
+attached, let alone to re-use that policy to add more statements to it.
+So it's safest to do nothing in these cases.
###### \`permission\`Required
- *Type:* PolicyStatement
+the policy statement to be added to the bucket's policy.
+
---
##### \`arnForObjects\`
@@ -1167,7 +1228,7 @@ Restrict the permission to a certain key pattern (default '*').
##### \`grantPublicAccess\`
\`\`\`wing
-grantPublicAccess(allowedActions: str, keyPrefix?: str): Grant
+grantPublicAccess(...allowedActions: Array, keyPrefix?: str): Grant
\`\`\`
Allows unrestricted access to objects from this bucket.
@@ -1187,6 +1248,10 @@ to an IPv4 range like this:
const grant = bucket.grantPublicAccess();
grant.resourceStatement!.addCondition(âIpAddressâ, { âaws:SourceIpâ: â54.240.143.0/24â });
+Note that if this \`IBucket\` refers to an existing bucket, possibly not
+managed by CloudFormation, this method will have no effect, since it's
+impossible to modify the policy of an existing bucket.
+
###### \`allowedActions\`Required
- *Type:* str
@@ -1419,45 +1484,66 @@ Options for adding the rule.
s3UrlForObject(key?: str): str
\`\`\`
-The S3 URL of an S3 object.
+The S3 URL of an S3 object. For example:.
-For example:
+\`s3://onlybucket\`
+- \`s3://bucket/key\`
-*Example*
+###### \`key\`Optional
+
+- *Type:* str
+
+The S3 key of the object.
+
+If not specified, the S3 URL of the
+bucket is returned.
+
+---
+
+##### \`transferAccelerationUrlForObject\`
\`\`\`wing
-s3://bucket/key
+transferAccelerationUrlForObject(key?: str, options?: TransferAccelerationUrlOptions): str
\`\`\`
+The https Transfer Acceleration URL of an S3 object.
-###### \`key\`Optional
+Specify \`dualStack: true\` at the options
+for dual-stack endpoint (connect to the bucket over IPv6). For example:
+
+- \`https://bucket.s3-accelerate.amazonaws.com\`
+- \`https://bucket.s3-accelerate.amazonaws.com/key\`
+
+###### \`key\`Optional
- *Type:* str
The S3 key of the object.
-If not specified, the S3 URL of the
+If not specified, the URL of the
bucket is returned.
---
-##### \`urlForObject\`
+###### \`options\`Optional
-\`\`\`wing
-urlForObject(key?: str): str
-\`\`\`
+- *Type:* TransferAccelerationUrlOptions
-The https URL of an S3 object.
+Options for generating URL.
-Specify \`regional: false\` at the options
-for non-regional URLs. For example:
+---
-*Example*
+##### \`urlForObject\`
\`\`\`wing
-https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey
+urlForObject(key?: str): str
\`\`\`
+The https URL of an S3 object. Specify \`regional: false\` at the options for non-regional URLs. For example:.
+
+\`https://s3.us-west-1.amazonaws.com/onlybucket\`
+- \`https://s3.us-west-1.amazonaws.com/bucket/key\`
+- \`https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey\`
###### \`key\`Optional
@@ -1476,17 +1562,12 @@ bucket is returned.
virtualHostedUrlForObject(key?: str, options?: VirtualHostedStyleUrlOptions): str
\`\`\`
-The virtual hosted-style URL of an S3 object.
-
-Specify \`regional: false\` at
-the options for non-regional URL. For example:
-
-*Example*
-
-\`\`\`wing
-https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey
-\`\`\`
+The virtual hosted-style URL of an S3 object. Specify \`regional: false\` at the options for non-regional URL. For example:.
+\`https://only-bucket.s3.us-west-1.amazonaws.com\`
+- \`https://bucket.s3.us-west-1.amazonaws.com/key\`
+- \`https://bucket.s3.amazonaws.com/key\`
+- \`https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey\`
###### \`key\`Optional
@@ -1585,6 +1666,7 @@ greet(): void
| fromBucketArn | *No description.* |
| fromBucketAttributes | Creates a Bucket construct that represents an external bucket. |
| fromBucketName | *No description.* |
+| validateBucketName | Thrown an exception if the given bucket name is not valid. |
---
@@ -1653,6 +1735,24 @@ GreeterBucket.fromBucketName(bucketName: str);
---
+##### \`validateBucketName\`
+
+\`\`\`wing
+bring { GreeterBucket } from \\"construct-library\\";
+
+GreeterBucket.validateBucketName(physicalName: str);
+\`\`\`
+
+Thrown an exception if the given bucket name is not valid.
+
+###### \`physicalName\`Required
+
+- *Type:* str
+
+name of the bucket.
+
+---
+
#### Properties
| **Name** | **Type** | **Description** |
diff --git a/apps/vscode-wing/.projen/deps.json b/apps/vscode-wing/.projen/deps.json
index 8a7d2e139eb..432892546f0 100644
--- a/apps/vscode-wing/.projen/deps.json
+++ b/apps/vscode-wing/.projen/deps.json
@@ -77,7 +77,7 @@
},
{
"name": "node-fetch",
- "version": "2",
+ "version": "^2.6.7",
"type": "build"
},
{
diff --git a/apps/vscode-wing/.projen/tasks.json b/apps/vscode-wing/.projen/tasks.json
index acba9e455ff..07e05df05de 100644
--- a/apps/vscode-wing/.projen/tasks.json
+++ b/apps/vscode-wing/.projen/tasks.json
@@ -165,25 +165,25 @@
"exec": "pnpm update npm-check-updates"
},
{
- "exec": "npm-check-updates --dep dev --upgrade --target=minor --reject='@wingconsole/app,@wingconsole/server,node-fetch,winglang'"
+ "exec": "npm-check-updates --dep dev --upgrade --target=minor --reject='@wingconsole/app,@wingconsole/server,winglang'"
},
{
- "exec": "npm-check-updates --dep optional --upgrade --target=minor --reject='@wingconsole/app,@wingconsole/server,node-fetch,winglang'"
+ "exec": "npm-check-updates --dep bundle --upgrade --target=minor --reject='@wingconsole/app,@wingconsole/server,winglang'"
},
{
- "exec": "npm-check-updates --dep peer --upgrade --target=minor --reject='@wingconsole/app,@wingconsole/server,node-fetch,winglang'"
+ "exec": "npm-check-updates --dep peer --upgrade --target=minor --reject='@wingconsole/app,@wingconsole/server,winglang'"
},
{
- "exec": "npm-check-updates --dep prod --upgrade --target=minor --reject='@wingconsole/app,@wingconsole/server,node-fetch,winglang'"
+ "exec": "npm-check-updates --dep prod --upgrade --target=minor --reject='@wingconsole/app,@wingconsole/server,winglang'"
},
{
- "exec": "npm-check-updates --dep bundle --upgrade --target=minor --reject='@wingconsole/app,@wingconsole/server,node-fetch,winglang'"
+ "exec": "npm-check-updates --dep optional --upgrade --target=minor --reject='@wingconsole/app,@wingconsole/server,winglang'"
},
{
"exec": "pnpm i --no-frozen-lockfile"
},
{
- "exec": "pnpm update"
+ "exec": "pnpm update @trpc/client @types/node-fetch @types/node @types/vscode @types/which @types/ws @typescript-eslint/eslint-plugin @typescript-eslint/parser @vscode/vsce @wingconsole/app @wingconsole/server eslint-config-prettier eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint node-fetch npm-check-updates open prettier projen ts-node tsup typescript vscode-languageclient which winglang ws"
},
{
"exec": "pnpm exec projen"
@@ -204,7 +204,7 @@
}
},
"env": {
- "PATH": "$(pnpm -c exec \"node -e \\\"console.log(process.env.PATH)\\\"\")"
+ "PATH": "$(pnpm -c exec \"node --print process.env.PATH\")"
},
"//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"."
}
diff --git a/apps/vscode-wing/.projenrc.ts b/apps/vscode-wing/.projenrc.ts
index 153c2c3c3e8..f4628f85870 100644
--- a/apps/vscode-wing/.projenrc.ts
+++ b/apps/vscode-wing/.projenrc.ts
@@ -60,7 +60,7 @@ const project = new TypeScriptAppProject({
"@trpc/client",
"ws",
"open",
- "node-fetch@2",
+ "node-fetch@^2.6.7",
"@types/node",
"@types/which",
"@vscode/vsce",
diff --git a/apps/vscode-wing/package.json b/apps/vscode-wing/package.json
index da01e355863..7bf7c31cd52 100644
--- a/apps/vscode-wing/package.json
+++ b/apps/vscode-wing/package.json
@@ -29,7 +29,7 @@
"organization": true
},
"devDependencies": {
- "@trpc/client": "^10.30.0",
+ "@trpc/client": "^10.38.1",
"@types/node": "^16",
"@types/node-fetch": "^2.6.4",
"@types/vscode": "^1.70.0",
@@ -37,24 +37,24 @@
"@types/ws": "^8.5.5",
"@typescript-eslint/eslint-plugin": "^5",
"@typescript-eslint/parser": "^5",
- "@vscode/vsce": "^2.16.0",
+ "@vscode/vsce": "^2.21.0",
"@wingconsole/app": "workspace:^",
"@wingconsole/server": "workspace:^",
"eslint": "^8",
- "eslint-config-prettier": "^8.6.0",
- "eslint-import-resolver-node": "^0.3.7",
- "eslint-import-resolver-typescript": "^3.5.3",
- "eslint-plugin-import": "^2.27.5",
+ "eslint-config-prettier": "^8.10.0",
+ "eslint-import-resolver-node": "^0.3.9",
+ "eslint-import-resolver-typescript": "^3.6.0",
+ "eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^4.2.1",
- "node-fetch": "2",
+ "node-fetch": "^2.6.7",
"npm-check-updates": "^16",
- "open": "^8.4.0",
- "prettier": "^2.8.3",
- "projen": "^0.71.60",
+ "open": "^8.4.2",
+ "prettier": "^2.8.8",
+ "projen": "^0.71.163",
"ts-node": "^10.9.1",
"tsup": "^6.7.0",
- "typescript": "^4.9.4",
- "vscode-languageclient": "^8.0.2",
+ "typescript": "^4.9.5",
+ "vscode-languageclient": "^8.1.0",
"which": "^1.3.1",
"winglang": "workspace:^",
"ws": "^8.13.0"
diff --git a/apps/vscode-wing/src/console/console-manager.ts b/apps/vscode-wing/src/console/console-manager.ts
index 77520bad945..130ce361447 100644
--- a/apps/vscode-wing/src/console/console-manager.ts
+++ b/apps/vscode-wing/src/console/console-manager.ts
@@ -7,6 +7,8 @@ import {
ViewColumn,
Uri,
ExtensionContext,
+ Position,
+ Range,
} from "vscode";
import {
@@ -156,6 +158,42 @@ export const createConsoleManager = (
logger.appendLine(err);
},
});
+
+ instance.client.onOpenFileInEditor({
+ onData: async (data) => {
+ const path = data?.path;
+ const line = data?.line - 1 || 0;
+ const column = data?.column || 0;
+
+ const openEditor = window.visibleTextEditors.find((editor) => {
+ return editor.document.uri.fsPath === path;
+ });
+
+ if (!openEditor || !openEditor.viewColumn) {
+ await commands.executeCommand(
+ "vscode.open",
+ Uri.file(path),
+ new Position(line, column)
+ );
+ return;
+ }
+
+ await commands.executeCommand("workbench.action.focusFirstEditorGroup");
+ for (let i = 0; i < openEditor.viewColumn - 1; i++) {
+ await commands.executeCommand("workbench.action.focusNextGroup");
+ }
+ await window.showTextDocument(openEditor.document, {
+ selection: new Range(
+ new Position(line, column),
+ new Position(line, column)
+ ),
+ });
+ },
+ onError: (err) => {
+ logger.appendLine(err);
+ },
+ });
+
instances[instance.id] = instance;
await setActiveInstance(instance.id);
@@ -244,11 +282,6 @@ export const createConsoleManager = (
});
context.subscriptions.push(webviewPanel, explorerView, testsExplorerView);
-
- const node = await resourcesExplorer.getChildren();
- if (node[0]?.id) {
- await explorerView?.reveal(new ResourceItem(node[0].id));
- }
activeInstanceId = instanceId;
};
diff --git a/apps/vscode-wing/src/console/services/client.ts b/apps/vscode-wing/src/console/services/client.ts
index 8a14520cbd0..5e40eab7f50 100644
--- a/apps/vscode-wing/src/console/services/client.ts
+++ b/apps/vscode-wing/src/console/services/client.ts
@@ -25,6 +25,7 @@ export interface Client {
runAllTests: () => Promise;
listResources: () => Promise;
onInvalidateQuery: (options: SubscriptionOptions) => void;
+ onOpenFileInEditor: (options: SubscriptionOptions) => void;
close: () => void;
}
@@ -98,6 +99,13 @@ export const createClient = (host: string): Client => {
return client["app.invalidateQuery"].subscribe(undefined, options);
};
+ const onOpenFileInEditor = (options: SubscriptionOptions) => {
+ return client["app.openFileInEditorSubscription"].subscribe(
+ undefined,
+ options
+ );
+ };
+
const close = () => {
wsClient.close();
};
@@ -112,6 +120,7 @@ export const createClient = (host: string): Client => {
runAllTests,
listResources,
onInvalidateQuery,
+ onOpenFileInEditor,
close,
};
};
diff --git a/apps/vscode-wing/syntaxes/wing.tmLanguage.json b/apps/vscode-wing/syntaxes/wing.tmLanguage.json
index de73bc41a79..376a3fbd9e1 100644
--- a/apps/vscode-wing/syntaxes/wing.tmLanguage.json
+++ b/apps/vscode-wing/syntaxes/wing.tmLanguage.json
@@ -109,7 +109,7 @@
"patterns": [
{
"name": "keyword.control.flow.wing",
- "match": "\\b(else|elif|if|return|try|catch|finally|bring|as)\\b"
+ "match": "\\b(else|elif|if|return|throw|try|catch|finally|bring|as)\\b"
},
{
"name": "keyword.control.loop.wing",
diff --git a/apps/vscode-wing/turbo.json b/apps/vscode-wing/turbo.json
index 1dd1dd3b453..d081804a948 100644
--- a/apps/vscode-wing/turbo.json
+++ b/apps/vscode-wing/turbo.json
@@ -6,9 +6,7 @@
"outputs": ["lib/**"]
},
"dev": {
- "dependsOn": ["compile"],
- "cache": false,
- "persistent": true
+ "dependsOn": ["compile"]
},
"package": {
"inputs": ["syntaxes/**", "resources/**"],
diff --git a/apps/wing-api-checker/.projen/tasks.json b/apps/wing-api-checker/.projen/tasks.json
index f129c8a33c0..05641fb5850 100644
--- a/apps/wing-api-checker/.projen/tasks.json
+++ b/apps/wing-api-checker/.projen/tasks.json
@@ -222,7 +222,7 @@
"exec": "npm-check-updates --dep dev --upgrade --target=minor"
},
{
- "exec": "npm-check-updates --dep optional --upgrade --target=minor"
+ "exec": "npm-check-updates --dep bundle --upgrade --target=minor"
},
{
"exec": "npm-check-updates --dep peer --upgrade --target=minor"
@@ -231,13 +231,13 @@
"exec": "npm-check-updates --dep prod --upgrade --target=minor"
},
{
- "exec": "npm-check-updates --dep bundle --upgrade --target=minor"
+ "exec": "npm-check-updates --dep optional --upgrade --target=minor"
},
{
"exec": "pnpm i --no-frozen-lockfile"
},
{
- "exec": "pnpm update"
+ "exec": "pnpm update @types/jest @types/node @types/yargs @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint jest jest-junit npm-check-updates prettier projen standard-version ts-jest ts-node typescript chalk chokidar glob-promise jsii-reflect yargs"
},
{
"exec": "pnpm exec projen"
@@ -258,7 +258,7 @@
}
},
"env": {
- "PATH": "$(pnpm -c exec \"node -e \\\"console.log(process.env.PATH)\\\"\")"
+ "PATH": "$(pnpm -c exec \"node --print process.env.PATH\")"
},
"//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"."
}
diff --git a/apps/wing-api-checker/package.json b/apps/wing-api-checker/package.json
index 3920459a1b4..86287db9682 100644
--- a/apps/wing-api-checker/package.json
+++ b/apps/wing-api-checker/package.json
@@ -34,33 +34,33 @@
"organization": true
},
"devDependencies": {
- "@types/jest": "^29.2.6",
+ "@types/jest": "^29.5.4",
"@types/node": "^16",
"@types/yargs": "^16.0.5",
"@typescript-eslint/eslint-plugin": "^5",
"@typescript-eslint/parser": "^5",
"eslint": "^8",
- "eslint-config-prettier": "^8.6.0",
- "eslint-import-resolver-node": "^0.3.7",
- "eslint-import-resolver-typescript": "^3.5.3",
- "eslint-plugin-import": "^2.27.5",
+ "eslint-config-prettier": "^8.10.0",
+ "eslint-import-resolver-node": "^0.3.9",
+ "eslint-import-resolver-typescript": "^3.6.0",
+ "eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^4.2.1",
- "jest": "^29.3.1",
+ "jest": "^29.6.4",
"jest-junit": "^15",
"npm-check-updates": "^16",
- "prettier": "^2.8.3",
- "projen": "^0.71.60",
+ "prettier": "^2.8.8",
+ "projen": "^0.71.163",
"standard-version": "^9",
- "ts-jest": "^29.0.5",
+ "ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
- "typescript": "^4.9.4"
+ "typescript": "^4.9.5"
},
"dependencies": {
"chalk": "^4.1.2",
"chokidar": "^3.5.3",
- "glob-promise": "^6.0.2",
- "jsii-reflect": "^1.73.0",
- "yargs": "^17.6.2"
+ "glob-promise": "^6.0.3",
+ "jsii-reflect": "^1.88.0",
+ "yargs": "^17.7.2"
},
"main": "lib/index.js",
"license": "MIT",
diff --git a/apps/wing-console/console/app/package.json b/apps/wing-console/console/app/package.json
index 76a915adad8..b809d31e5a8 100644
--- a/apps/wing-console/console/app/package.json
+++ b/apps/wing-console/console/app/package.json
@@ -18,35 +18,35 @@
"package": "bump-pack -b"
},
"dependencies": {
- "@segment/analytics-node": "^1.0.0",
+ "@segment/analytics-node": "^1.1.0",
"@wingconsole/server": "workspace:^",
"express": "^4.18.2"
},
"devDependencies": {
"@ibm/plex": "^6.3.0",
- "@playwright/test": "^1.35.1",
+ "@playwright/test": "^1.37.1",
"@tailwindcss/forms": "^0.5.3",
"@types/express": "^4.17.17",
- "@types/react": "^18.2.12",
- "@types/react-dom": "^18.2.5",
- "@vitejs/plugin-react": "^4.0.0",
+ "@types/react": "^18.2.21",
+ "@types/react-dom": "^18.2.7",
+ "@vitejs/plugin-react": "^4.0.4",
"@vitest/coverage-c8": "^0.31.4",
"@wingconsole/eslint-plugin": "workspace:^",
"@wingconsole/tsconfig": "workspace:^",
"@wingconsole/ui": "workspace:^",
- "autoprefixer": "^10.4.14",
+ "autoprefixer": "^10.4.15",
"bump-pack": "workspace:^",
- "conf": "^11.0.1",
- "eslint": "^8.42.0",
+ "conf": "^11.0.2",
+ "eslint": "^8.48.0",
"nanoid": "^4.0.2",
"open": "^9.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
- "tailwindcss": "^3.3.2",
+ "tailwindcss": "^3.3.3",
"tsup": "^6.7.0",
- "tsx": "^3.12.7",
- "typescript": "^5.1.3",
- "vite": "^4.3.9"
+ "tsx": "^3.12.8",
+ "typescript": "^5.2.2",
+ "vite": "^4.4.9"
},
"volta": {
"extends": "../../../../package.json"
diff --git a/apps/wing-console/console/app/preview/Dockerfile b/apps/wing-console/console/app/preview/Dockerfile
new file mode 100644
index 00000000000..ddd95c512a1
--- /dev/null
+++ b/apps/wing-console/console/app/preview/Dockerfile
@@ -0,0 +1,11 @@
+FROM node:18.16.0-alpine
+
+WORKDIR /app
+
+COPY dist dist
+COPY apps/wing-console/console/app/preview/index.mjs dist/
+COPY apps/wing-console/console/app/demo demo
+
+RUN npm init -y && npm install --no-package-lock ./dist/*-[0-9]*.[0-9]*.[0-9]*.tgz
+
+ENTRYPOINT ["node", "dist/index.mjs"]
diff --git a/apps/wing-console/console/app/preview/fly.toml b/apps/wing-console/console/app/preview/fly.toml
new file mode 100644
index 00000000000..22195ea18cc
--- /dev/null
+++ b/apps/wing-console/console/app/preview/fly.toml
@@ -0,0 +1,25 @@
+primary_region = "lhr"
+
+[build]
+ dockerfile = "Dockerfile"
+ ignorefile = ".dockerignore"
+
+[[services]]
+ protocol = "tcp"
+ internal_port = 3000
+ auto_stop_machines = false
+ auto_start_machines = false
+ min_machines_running = 1
+
+ [services.concurrency]
+ hard_limit = 250
+ soft_limit = 200
+ type = "connections"
+
+ [[services.ports]]
+ port = 80
+ handlers = ["http"]
+
+ [[services.ports]]
+ port = 443
+ handlers = ["tls", "http"]
diff --git a/apps/wing-console/console/app/preview/index.mjs b/apps/wing-console/console/app/preview/index.mjs
new file mode 100644
index 00000000000..daa95a0b8c1
--- /dev/null
+++ b/apps/wing-console/console/app/preview/index.mjs
@@ -0,0 +1,7 @@
+import { fileURLToPath } from "node:url";
+import { createConsoleApp } from "@wingconsole/app";
+
+await createConsoleApp({
+ wingfile: fileURLToPath(new URL("../demo/index.w", import.meta.url)),
+ requestedPort: 3000,
+});
diff --git a/apps/wing-console/console/app/test/describe.ts b/apps/wing-console/console/app/test/describe.ts
index d2c33c0cf93..0342aa1a11f 100644
--- a/apps/wing-console/console/app/test/describe.ts
+++ b/apps/wing-console/console/app/test/describe.ts
@@ -36,8 +36,6 @@ export const describe = (wingfile: string, callback: () => void) => {
await page.goto(`http://localhost:${server.port}/`);
- await page.getByTestId("loading-overlay").waitFor({ state: "hidden" });
-
await page.waitForLoadState("domcontentloaded");
});
diff --git a/apps/wing-console/console/app/turbo.json b/apps/wing-console/console/app/turbo.json
index 25400ee13dc..475d88883d9 100644
--- a/apps/wing-console/console/app/turbo.json
+++ b/apps/wing-console/console/app/turbo.json
@@ -8,6 +8,10 @@
},
"package": {
"outputs": ["../../../../dist/wingconsole-app-*.tgz"]
+ },
+ "preview:fly": {
+ "dependsOn": ["compile"],
+ "inputs": ["demo/*", "preview/*"]
}
}
}
diff --git a/apps/wing-console/console/app/web/index.tsx b/apps/wing-console/console/app/web/index.tsx
index 37cd6e0f0af..3786d2399e3 100644
--- a/apps/wing-console/console/app/web/index.tsx
+++ b/apps/wing-console/console/app/web/index.tsx
@@ -8,7 +8,9 @@ ReactDOM.createRoot(document.querySelector("#root")!).render(
{
- return item.label?.toLowerCase().includes(value.toLowerCase());
+ return item.label?.toLowerCase().includes(value?.toLowerCase());
}),
);
}, [items, value, filter]);
diff --git a/apps/wing-console/console/design-system/src/key-value-list.tsx b/apps/wing-console/console/design-system/src/key-value-list.tsx
index 8c4f55d7512..a58cbc09e41 100644
--- a/apps/wing-console/console/design-system/src/key-value-list.tsx
+++ b/apps/wing-console/console/design-system/src/key-value-list.tsx
@@ -1,6 +1,11 @@
import { PlusIcon, TrashIcon } from "@heroicons/react/24/outline";
import classNames from "classnames";
-import { useCallback, useEffect, useState } from "react";
+import {
+ useCallback,
+ useEffect,
+ useState as useReactState,
+ useState,
+} from "react";
import { Button } from "./button.js";
import { Combobox } from "./combobox.js";
@@ -11,7 +16,13 @@ export interface KeyValueItem {
value: string;
}
-export const useKeyValueList = () => {
+export interface UseKeyValueListOptions {
+ useState?: typeof useReactState;
+}
+
+export const useKeyValueList = ({
+ useState = useReactState,
+}: UseKeyValueListOptions) => {
const [items, setItems] = useState([]);
const addItem = useCallback((item: KeyValueItem) => {
@@ -86,7 +97,7 @@ export const KeyValueList = ({
return;
}
setEditItems([...items, { key: "", value: "" }]);
- }, [readonly, items]);
+ }, [readonly, items, onAddItem]);
const onItemChange = (index: number, item: KeyValueItem) => {
if (index === items.length) {
diff --git a/apps/wing-console/console/design-system/src/left-resizable-widget.tsx b/apps/wing-console/console/design-system/src/left-resizable-widget.tsx
index 74d659a8074..565090330f8 100644
--- a/apps/wing-console/console/design-system/src/left-resizable-widget.tsx
+++ b/apps/wing-console/console/design-system/src/left-resizable-widget.tsx
@@ -17,7 +17,7 @@ export function LeftResizableWidget(props: LeftResizableWidgetProps) {