The CDK Construct Library for AWS::Amplify
Project description
AWS Amplify Construct Library
---This is a developer preview (public beta) module.
All classes with the
Cfn
prefix in this module (CFN Resources) are auto-generated from CloudFormation. They are stable and safe to use.However, all other classes, i.e., higher level constructs, are under active development and subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
The AWS Amplify Console provides a Git-based workflow for deploying and hosting fullstack serverless web applications. A fullstack serverless app consists of a backend built with cloud resources such as GraphQL or REST APIs, file and data storage, and a frontend built with single page application frameworks such as React, Angular, Vue, or Gatsby.
Setting up an app with branches, custom rules and a domain
To set up an Amplify Console app, define an App
:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_codebuild as codebuild
import aws_cdk.aws_amplify as amplify
import aws_cdk.core as cdk
amplify_app = amplify.App(self, "MyApp",
repository="https://github.com/<user>/<repo>",
oauth_token=cdk.SecretValue.secrets_manager("my-github-token"),
build_spec=codebuild.BuildSpec.from_object({# Alternatively add a `amplify.yml` to the repo
"version": "1.0",
"frontend": {
"phases": {
"pre_build": {
"commands": ["yarn"
]
},
"build": {
"commands": ["yarn build"
]
}
},
"artifacts": {
"base_directory": "public",
"files": "**/*"
}
}})
)
Add branches:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
master = amplify_app.add_branch("master")# `id` will be used as repo branch name
dev = amplify_app.add_branch("dev")
dev.add_environment("STAGE", "dev")
Auto build and pull request preview are enabled by default.
Add custom rules for redirection:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
amplify_app.add_custom_rule(
source="/docs/specific-filename.html",
target="/documents/different-filename.html",
status=amplify.RedirectStatus.TEMPORARY_REDIRECT
)
Add a domain and map sub domains to branches:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
domain = amplify_app.add_domain("example.com")
domain.map_sub_domain(master, "www")
domain.map_sub_domain(dev)
Restricting access
Password protect the app with basic auth by specifying the basicAuth
prop.
Use BasicAuth.fromCredentials
when referencing an existing secret:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
amplify_app = amplify.App(self, "MyApp",
repository="https://github.com/<user>/<repo>",
oauth_token=cdk.SecretValue.secrets_manager("my-github-token"),
basic_auth=amplify.BasicAuth.from_credentials("username", cdk.SecretValue.secrets_manager("my-github-token"))
)
Use BasicAuth.fromGeneratedPassword
to generate a password in Secrets Manager:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
amplify_app = amplify.App(self, "MyApp",
repository="https://github.com/<user>/<repo>",
oauth_token=cdk.SecretValue.secrets_manager("my-github-token"),
basic_auth=amplify.BasicAuth.from_generated_password("username")
)
Basic auth can be added to specific branches:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
app.add_branch("feature/next",
basic_auth=amplify.BasicAuth.from_generated_password("username")
)
Automatically creating branches
Use the autoBranchCreation
prop to automatically create new branches:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
amplify_app = amplify.App(self, "MyApp",
repository="https://github.com/<user>/<repo>",
oauth_token=cdk.SecretValue.secrets_manager("my-github-token"),
auto_branch_creation={
"patterns": ["feature/*", "test/*"]
}
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aws-cdk.aws-amplify-1.31.0.tar.gz
.
File metadata
- Download URL: aws-cdk.aws-amplify-1.31.0.tar.gz
- Upload date:
- Size: 83.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d65294f614076154b9468b332869b6d9aa8a9127d3857e89dff0878d98af906b |
|
MD5 | 126281fb4f3eb7bf65fd901f959921af |
|
BLAKE2b-256 | 6aaf7e3d03bb30ccfb41978615607c69724af8af89a85bb44911dab4b6ae5050 |
File details
Details for the file aws_cdk.aws_amplify-1.31.0-py3-none-any.whl
.
File metadata
- Download URL: aws_cdk.aws_amplify-1.31.0-py3-none-any.whl
- Upload date:
- Size: 81.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 088212b933e98b1ff5afe30866ad0fbe2aea66dd4613efdecdd53c25c3114946 |
|
MD5 | 9de48960a46ff17c6ff46c4874f0d960 |
|
BLAKE2b-256 | be8bf4d7383c8e50259b72c8602242446786e2ae5fca304b862961c7c5516d01 |