From e16633399681e8ed8dff5cf4f04f35ecff1e1e4d Mon Sep 17 00:00:00 2001 From: andyu17 Date: Sat, 18 Jan 2025 22:12:05 +0900 Subject: [PATCH 1/2] docs(amplify-alpha): fix typo --- packages/@aws-cdk/aws-amplify-alpha/README.md | 130 +++++++++--------- 1 file changed, 66 insertions(+), 64 deletions(-) diff --git a/packages/@aws-cdk/aws-amplify-alpha/README.md b/packages/@aws-cdk/aws-amplify-alpha/README.md index eaeed3c8b9c33..2d0ec4a1f3e53 100644 --- a/packages/@aws-cdk/aws-amplify-alpha/README.md +++ b/packages/@aws-cdk/aws-amplify-alpha/README.md @@ -1,4 +1,5 @@ # AWS Amplify Construct Library + --- @@ -22,34 +23,29 @@ The AWS Amplify Console provides a Git-based workflow for deploying and hosting To set up an Amplify Console app, define an `App`: ```ts -import * as codebuild from 'aws-cdk-lib/aws-codebuild'; +import * as codebuild from "aws-cdk-lib/aws-codebuild"; -const amplifyApp = new amplify.App(this, 'MyApp', { +const amplifyApp = new amplify.App(this, "MyApp", { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: '', - repository: '', - oauthToken: SecretValue.secretsManager('my-github-token'), + owner: "", + repository: "", + oauthToken: SecretValue.secretsManager("my-github-token"), }), buildSpec: codebuild.BuildSpec.fromObjectToYaml({ // Alternatively add a `amplify.yml` to the repo - version: '1.0', + version: "1.0", frontend: { phases: { preBuild: { - commands: [ - 'yarn', - ], + commands: ["yarn"], }, build: { - commands: [ - 'yarn build', - ], + commands: ["yarn build"], }, }, artifacts: { - baseDirectory: 'public', - files: - - '**/*', + baseDirectory: "public", + files: -"**/*", }, }, }), @@ -59,11 +55,11 @@ const amplifyApp = new amplify.App(this, 'MyApp', { To connect your `App` to GitLab, use the `GitLabSourceCodeProvider`: ```ts -const amplifyApp = new amplify.App(this, 'MyApp', { +const amplifyApp = new amplify.App(this, "MyApp", { sourceCodeProvider: new amplify.GitLabSourceCodeProvider({ - owner: '', - repository: '', - oauthToken: SecretValue.secretsManager('my-gitlab-token'), + owner: "", + repository: "", + oauthToken: SecretValue.secretsManager("my-gitlab-token"), }), }); ``` @@ -71,13 +67,13 @@ const amplifyApp = new amplify.App(this, 'MyApp', { To connect your `App` to CodeCommit, use the `CodeCommitSourceCodeProvider`: ```ts -import * as codecommit from 'aws-cdk-lib/aws-codecommit'; +import * as codecommit from "aws-cdk-lib/aws-codecommit"; -const repository = new codecommit.Repository(this, 'Repo', { - repositoryName: 'my-repo', +const repository = new codecommit.Repository(this, "Repo", { + repositoryName: "my-repo", }); -const amplifyApp = new amplify.App(this, 'App', { +const amplifyApp = new amplify.App(this, "App", { sourceCodeProvider: new amplify.CodeCommitSourceCodeProvider({ repository }), }); ``` @@ -90,11 +86,11 @@ Add branches: ```ts declare const amplifyApp: amplify.App; -const main = amplifyApp.addBranch('main'); // `id` will be used as repo branch name -const dev = amplifyApp.addBranch('dev', { +const main = amplifyApp.addBranch("main"); // `id` will be used as repo branch name +const dev = amplifyApp.addBranch("dev", { performanceMode: true, // optional, enables performance mode }); -dev.addEnvironment('STAGE', 'dev'); +dev.addEnvironment("STAGE", "dev"); ``` Auto build and pull request preview are enabled by default. @@ -104,8 +100,8 @@ Add custom rules for redirection: ```ts declare const amplifyApp: amplify.App; amplifyApp.addCustomRule({ - source: '/docs/specific-filename.html', - target: '/documents/different-filename.html', + source: "/docs/specific-filename.html", + target: "/documents/different-filename.html", status: amplify.RedirectStatus.TEMPORARY_REDIRECT, }); ``` @@ -119,7 +115,9 @@ ttf, map, json, webmanifest. ```ts declare const mySinglePageApp: amplify.App; -mySinglePageApp.addCustomRule(amplify.CustomRule.SINGLE_PAGE_APPLICATION_REDIRECT); +mySinglePageApp.addCustomRule( + amplify.CustomRule.SINGLE_PAGE_APPLICATION_REDIRECT +); ``` Add a domain and map sub domains to branches: @@ -129,12 +127,12 @@ declare const amplifyApp: amplify.App; declare const main: amplify.Branch; declare const dev: amplify.Branch; -const domain = amplifyApp.addDomain('example.com', { +const domain = amplifyApp.addDomain("example.com", { enableAutoSubdomain: true, // in case subdomains should be auto registered for branches - autoSubdomainCreationPatterns: ['*', 'pr*'], // regex for branches that should auto register subdomains + autoSubdomainCreationPatterns: ["*", "pr*"], // regex for branches that should auto register subdomains }); domain.mapRoot(main); // map main branch to domain root -domain.mapSubDomain(main, 'www'); +domain.mapSubDomain(main, "www"); domain.mapSubDomain(dev); // sub domain prefix defaults to branch name ``` @@ -144,7 +142,7 @@ To specify a custom certificate for your custom domain use the `customCertificat declare const customCertificate: acm.Certificate; declare const amplifyApp: amplify.App; -const domain = amplifyApp.addDomain('example.com', { +const domain = amplifyApp.addDomain("example.com", { customCertificate, // set your custom certificate }); ``` @@ -156,26 +154,29 @@ Password protect the app with basic auth by specifying the `basicAuth` prop. Use `BasicAuth.fromCredentials` when referencing an existing secret: ```ts -const amplifyApp = new amplify.App(this, 'MyApp', { +const amplifyApp = new amplify.App(this, "MyApp", { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: '', - repository: '', - oauthToken: SecretValue.secretsManager('my-github-token'), + owner: "", + repository: "", + oauthToken: SecretValue.secretsManager("my-github-token"), }), - basicAuth: amplify.BasicAuth.fromCredentials('username', SecretValue.secretsManager('my-github-token')), + basicAuth: amplify.BasicAuth.fromCredentials( + "username", + SecretValue.secretsManager("my-github-token") + ), }); ``` Use `BasicAuth.fromGeneratedPassword` to generate a password in Secrets Manager: ```ts -const amplifyApp = new amplify.App(this, 'MyApp', { +const amplifyApp = new amplify.App(this, "MyApp", { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: '', - repository: '', - oauthToken: SecretValue.secretsManager('my-github-token'), + owner: "", + repository: "", + oauthToken: SecretValue.secretsManager("my-github-token"), }), - basicAuth: amplify.BasicAuth.fromGeneratedPassword('username'), + basicAuth: amplify.BasicAuth.fromGeneratedPassword("username"), }); ``` @@ -183,8 +184,8 @@ Basic auth can be added to specific branches: ```ts declare const amplifyApp: amplify.App; -amplifyApp.addBranch('feature/next', { - basicAuth: amplify.BasicAuth.fromGeneratedPassword('username'), +amplifyApp.addBranch("feature/next", { + basicAuth: amplify.BasicAuth.fromGeneratedPassword("username"), }); ``` @@ -194,14 +195,15 @@ Use the `autoBranchCreation` and `autoBranchDeletion` props to control creation/ of branches: ```ts -const amplifyApp = new amplify.App(this, 'MyApp', { +const amplifyApp = new amplify.App(this, "MyApp", { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: '', - repository: '', - oauthToken: SecretValue.secretsManager('my-github-token'), + owner: "", + repository: "", + oauthToken: SecretValue.secretsManager("my-github-token"), }), - autoBranchCreation: { // Automatically connect branches that match a pattern set - patterns: ['feature/*', 'test/*'], + autoBranchCreation: { + // Automatically connect branches that match a pattern set + patterns: ["feature/*", "test/*"], }, autoBranchDeletion: true, // Automatically disconnect a branch when you delete a branch from your repository }); @@ -212,24 +214,24 @@ const amplifyApp = new amplify.App(this, 'MyApp', { Use the `customResponseHeaders` prop to configure custom response headers for an Amplify app: ```ts -const amplifyApp = new amplify.App(this, 'App', { +const amplifyApp = new amplify.App(this, "App", { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: '', - repository: '', - oauthToken: SecretValue.secretsManager('my-github-token'), + owner: "", + repository: "", + oauthToken: SecretValue.secretsManager("my-github-token"), }), customResponseHeaders: [ { - pattern: '*.json', + pattern: "*.json", headers: { - 'custom-header-name-1': 'custom-header-value-1', - 'custom-header-name-2': 'custom-header-value-2', + "custom-header-name-1": "custom-header-value-1", + "custom-header-name-2": "custom-header-value-2", }, }, { - pattern: '/path/*', + pattern: "/path/*", headers: { - 'custom-header-name-1': 'custom-header-value-2', + "custom-header-name-1": "custom-header-value-2", }, }, ], @@ -241,7 +243,7 @@ const amplifyApp = new amplify.App(this, 'App', { Setting the `platform` field on the Amplify `App` construct can be used to control whether the app will host only static assets or server side rendered assets in addition to static. By default, the value is set to `WEB` (static only), however, server side rendering can be turned on by setting to `WEB_COMPUTE` as follows: ```ts -const amplifyApp = new amplify.App(this, 'MyApp', { +const amplifyApp = new amplify.App(this, "MyApp", { platform: amplify.Platform.WEB_COMPUTE, }); ``` @@ -250,12 +252,12 @@ const amplifyApp = new amplify.App(this, 'MyApp', { Amplify uses Amazon CloudFront to manage the caching configuration for your hosted applications. A cache configuration is applied to each app to optimize for the best performance. -Setting the `cacheConfigType` field on the Amplify `App` construct can be used to control cache configguration. By default, the value is set to `AMPLIFY_MANAGED`. If you want to exclude all cookies from the cache key, set `AMPLIFY_MANAGED_NO_COOKIES`. +Setting the `cacheConfigType` field on the Amplify `App` construct can be used to control cache configuration. By default, the value is set to `AMPLIFY_MANAGED`. If you want to exclude all cookies from the cache key, set `AMPLIFY_MANAGED_NO_COOKIES`. For more information, see [Managing the cache configuration for an app](https://docs.aws.amazon.com/amplify/latest/userguide/caching.html). ```ts -const amplifyApp = new amplify.App(this, 'MyApp', { +const amplifyApp = new amplify.App(this, "MyApp", { cacheConfigType: amplify.CacheConfigType.AMPLIFY_MANAGED_NO_COOKIES, }); ``` @@ -265,7 +267,7 @@ const amplifyApp = new amplify.App(this, 'MyApp', { `sourceCodeProvider` is optional; when this is not specified the Amplify app can be deployed to using `.zip` packages. The `asset` property can be used to deploy S3 assets to Amplify as part of the CDK: ```ts -import * as assets from 'aws-cdk-lib/aws-s3-assets'; +import * as assets from "aws-cdk-lib/aws-s3-assets"; declare const asset: assets.Asset; declare const amplifyApp: amplify.App; From b6a9402e6a1ee33a9345d92bbfe572ea3d7b344a Mon Sep 17 00:00:00 2001 From: andyu17 Date: Sat, 18 Jan 2025 22:15:45 +0900 Subject: [PATCH 2/2] docs(amplify-alpha): fix typo2 --- packages/@aws-cdk/aws-amplify-alpha/README.md | 128 +++++++++--------- 1 file changed, 63 insertions(+), 65 deletions(-) diff --git a/packages/@aws-cdk/aws-amplify-alpha/README.md b/packages/@aws-cdk/aws-amplify-alpha/README.md index 2d0ec4a1f3e53..fb062ae9a56f6 100644 --- a/packages/@aws-cdk/aws-amplify-alpha/README.md +++ b/packages/@aws-cdk/aws-amplify-alpha/README.md @@ -1,5 +1,4 @@ # AWS Amplify Construct Library - --- @@ -23,29 +22,34 @@ The AWS Amplify Console provides a Git-based workflow for deploying and hosting To set up an Amplify Console app, define an `App`: ```ts -import * as codebuild from "aws-cdk-lib/aws-codebuild"; +import * as codebuild from 'aws-cdk-lib/aws-codebuild'; -const amplifyApp = new amplify.App(this, "MyApp", { +const amplifyApp = new amplify.App(this, 'MyApp', { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: "", - repository: "", - oauthToken: SecretValue.secretsManager("my-github-token"), + owner: '', + repository: '', + oauthToken: SecretValue.secretsManager('my-github-token'), }), buildSpec: codebuild.BuildSpec.fromObjectToYaml({ // Alternatively add a `amplify.yml` to the repo - version: "1.0", + version: '1.0', frontend: { phases: { preBuild: { - commands: ["yarn"], + commands: [ + 'yarn', + ], }, build: { - commands: ["yarn build"], + commands: [ + 'yarn build', + ], }, }, artifacts: { - baseDirectory: "public", - files: -"**/*", + baseDirectory: 'public', + files: + - '**/*', }, }, }), @@ -55,11 +59,11 @@ const amplifyApp = new amplify.App(this, "MyApp", { To connect your `App` to GitLab, use the `GitLabSourceCodeProvider`: ```ts -const amplifyApp = new amplify.App(this, "MyApp", { +const amplifyApp = new amplify.App(this, 'MyApp', { sourceCodeProvider: new amplify.GitLabSourceCodeProvider({ - owner: "", - repository: "", - oauthToken: SecretValue.secretsManager("my-gitlab-token"), + owner: '', + repository: '', + oauthToken: SecretValue.secretsManager('my-gitlab-token'), }), }); ``` @@ -67,13 +71,13 @@ const amplifyApp = new amplify.App(this, "MyApp", { To connect your `App` to CodeCommit, use the `CodeCommitSourceCodeProvider`: ```ts -import * as codecommit from "aws-cdk-lib/aws-codecommit"; +import * as codecommit from 'aws-cdk-lib/aws-codecommit'; -const repository = new codecommit.Repository(this, "Repo", { - repositoryName: "my-repo", +const repository = new codecommit.Repository(this, 'Repo', { + repositoryName: 'my-repo', }); -const amplifyApp = new amplify.App(this, "App", { +const amplifyApp = new amplify.App(this, 'App', { sourceCodeProvider: new amplify.CodeCommitSourceCodeProvider({ repository }), }); ``` @@ -86,11 +90,11 @@ Add branches: ```ts declare const amplifyApp: amplify.App; -const main = amplifyApp.addBranch("main"); // `id` will be used as repo branch name -const dev = amplifyApp.addBranch("dev", { +const main = amplifyApp.addBranch('main'); // `id` will be used as repo branch name +const dev = amplifyApp.addBranch('dev', { performanceMode: true, // optional, enables performance mode }); -dev.addEnvironment("STAGE", "dev"); +dev.addEnvironment('STAGE', 'dev'); ``` Auto build and pull request preview are enabled by default. @@ -100,8 +104,8 @@ Add custom rules for redirection: ```ts declare const amplifyApp: amplify.App; amplifyApp.addCustomRule({ - source: "/docs/specific-filename.html", - target: "/documents/different-filename.html", + source: '/docs/specific-filename.html', + target: '/documents/different-filename.html', status: amplify.RedirectStatus.TEMPORARY_REDIRECT, }); ``` @@ -115,9 +119,7 @@ ttf, map, json, webmanifest. ```ts declare const mySinglePageApp: amplify.App; -mySinglePageApp.addCustomRule( - amplify.CustomRule.SINGLE_PAGE_APPLICATION_REDIRECT -); +mySinglePageApp.addCustomRule(amplify.CustomRule.SINGLE_PAGE_APPLICATION_REDIRECT); ``` Add a domain and map sub domains to branches: @@ -127,12 +129,12 @@ declare const amplifyApp: amplify.App; declare const main: amplify.Branch; declare const dev: amplify.Branch; -const domain = amplifyApp.addDomain("example.com", { +const domain = amplifyApp.addDomain('example.com', { enableAutoSubdomain: true, // in case subdomains should be auto registered for branches - autoSubdomainCreationPatterns: ["*", "pr*"], // regex for branches that should auto register subdomains + autoSubdomainCreationPatterns: ['*', 'pr*'], // regex for branches that should auto register subdomains }); domain.mapRoot(main); // map main branch to domain root -domain.mapSubDomain(main, "www"); +domain.mapSubDomain(main, 'www'); domain.mapSubDomain(dev); // sub domain prefix defaults to branch name ``` @@ -142,7 +144,7 @@ To specify a custom certificate for your custom domain use the `customCertificat declare const customCertificate: acm.Certificate; declare const amplifyApp: amplify.App; -const domain = amplifyApp.addDomain("example.com", { +const domain = amplifyApp.addDomain('example.com', { customCertificate, // set your custom certificate }); ``` @@ -154,29 +156,26 @@ Password protect the app with basic auth by specifying the `basicAuth` prop. Use `BasicAuth.fromCredentials` when referencing an existing secret: ```ts -const amplifyApp = new amplify.App(this, "MyApp", { +const amplifyApp = new amplify.App(this, 'MyApp', { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: "", - repository: "", - oauthToken: SecretValue.secretsManager("my-github-token"), + owner: '', + repository: '', + oauthToken: SecretValue.secretsManager('my-github-token'), }), - basicAuth: amplify.BasicAuth.fromCredentials( - "username", - SecretValue.secretsManager("my-github-token") - ), + basicAuth: amplify.BasicAuth.fromCredentials('username', SecretValue.secretsManager('my-github-token')), }); ``` Use `BasicAuth.fromGeneratedPassword` to generate a password in Secrets Manager: ```ts -const amplifyApp = new amplify.App(this, "MyApp", { +const amplifyApp = new amplify.App(this, 'MyApp', { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: "", - repository: "", - oauthToken: SecretValue.secretsManager("my-github-token"), + owner: '', + repository: '', + oauthToken: SecretValue.secretsManager('my-github-token'), }), - basicAuth: amplify.BasicAuth.fromGeneratedPassword("username"), + basicAuth: amplify.BasicAuth.fromGeneratedPassword('username'), }); ``` @@ -184,8 +183,8 @@ Basic auth can be added to specific branches: ```ts declare const amplifyApp: amplify.App; -amplifyApp.addBranch("feature/next", { - basicAuth: amplify.BasicAuth.fromGeneratedPassword("username"), +amplifyApp.addBranch('feature/next', { + basicAuth: amplify.BasicAuth.fromGeneratedPassword('username'), }); ``` @@ -195,15 +194,14 @@ Use the `autoBranchCreation` and `autoBranchDeletion` props to control creation/ of branches: ```ts -const amplifyApp = new amplify.App(this, "MyApp", { +const amplifyApp = new amplify.App(this, 'MyApp', { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: "", - repository: "", - oauthToken: SecretValue.secretsManager("my-github-token"), + owner: '', + repository: '', + oauthToken: SecretValue.secretsManager('my-github-token'), }), - autoBranchCreation: { - // Automatically connect branches that match a pattern set - patterns: ["feature/*", "test/*"], + autoBranchCreation: { // Automatically connect branches that match a pattern set + patterns: ['feature/*', 'test/*'], }, autoBranchDeletion: true, // Automatically disconnect a branch when you delete a branch from your repository }); @@ -214,24 +212,24 @@ const amplifyApp = new amplify.App(this, "MyApp", { Use the `customResponseHeaders` prop to configure custom response headers for an Amplify app: ```ts -const amplifyApp = new amplify.App(this, "App", { +const amplifyApp = new amplify.App(this, 'App', { sourceCodeProvider: new amplify.GitHubSourceCodeProvider({ - owner: "", - repository: "", - oauthToken: SecretValue.secretsManager("my-github-token"), + owner: '', + repository: '', + oauthToken: SecretValue.secretsManager('my-github-token'), }), customResponseHeaders: [ { - pattern: "*.json", + pattern: '*.json', headers: { - "custom-header-name-1": "custom-header-value-1", - "custom-header-name-2": "custom-header-value-2", + 'custom-header-name-1': 'custom-header-value-1', + 'custom-header-name-2': 'custom-header-value-2', }, }, { - pattern: "/path/*", + pattern: '/path/*', headers: { - "custom-header-name-1": "custom-header-value-2", + 'custom-header-name-1': 'custom-header-value-2', }, }, ], @@ -243,7 +241,7 @@ const amplifyApp = new amplify.App(this, "App", { Setting the `platform` field on the Amplify `App` construct can be used to control whether the app will host only static assets or server side rendered assets in addition to static. By default, the value is set to `WEB` (static only), however, server side rendering can be turned on by setting to `WEB_COMPUTE` as follows: ```ts -const amplifyApp = new amplify.App(this, "MyApp", { +const amplifyApp = new amplify.App(this, 'MyApp', { platform: amplify.Platform.WEB_COMPUTE, }); ``` @@ -257,7 +255,7 @@ Setting the `cacheConfigType` field on the Amplify `App` construct can be used t For more information, see [Managing the cache configuration for an app](https://docs.aws.amazon.com/amplify/latest/userguide/caching.html). ```ts -const amplifyApp = new amplify.App(this, "MyApp", { +const amplifyApp = new amplify.App(this, 'MyApp', { cacheConfigType: amplify.CacheConfigType.AMPLIFY_MANAGED_NO_COOKIES, }); ``` @@ -267,7 +265,7 @@ const amplifyApp = new amplify.App(this, "MyApp", { `sourceCodeProvider` is optional; when this is not specified the Amplify app can be deployed to using `.zip` packages. The `asset` property can be used to deploy S3 assets to Amplify as part of the CDK: ```ts -import * as assets from "aws-cdk-lib/aws-s3-assets"; +import * as assets from 'aws-cdk-lib/aws-s3-assets'; declare const asset: assets.Asset; declare const amplifyApp: amplify.App;