Static Website CDK Packages
This package will provide stacks/managers to create multiple region buckets with replication along with setting up cloudfront.
| Stack | Description | --- | --- | ClientStack | This will configure CloudFront. This will also create the S3 bucket to host the website. It can also setup replication with other buckets (make sure those buckets are created first) | WebsiteBucketStack | This will allow for creation of website S3 buckets. It can be useful to use prior to the ClientStack when setting up replication
| Property | Required | Type | Description
| --- | --- | ---
| applicationName | Yes | string | Name of the application and used as a prefix for all lambda names
| environmentName | Yes | string | The logical environment (dev, qa, etc)
| enableWaf | No | boolean | Should a WAF be in front of the Cloudfront Configuration
| network | Yes | ClientStackNetworkProps | Network Configuration
| s3DefaultCacheTtl | No | Duration | s3DefaultCacheTtl (86400 is the default if not specified)
| removalPolicy | No | RemovalPolicy | When this stack is removed, what should happen to the bucket? (RemovalPolicy.RETAIN is the default)
| replication | No | WebsiteBucketReplicationProps | The failover bucket and the IAMFactory used to get the
| bucketName | No | string | The name of the bucket to store the artifacts. If not specified, the name will be
| Property | Required | Type | Description | --- | --- | --- | applicationName | Yes | string | Name of the application and used as a prefix for all lambda names | environmentName | Yes | string | The logical environment (dev, qa, etc) | bucketName | Yes | string | The name of the bucket | removalPolicy | No | RemovalPolicy | When this stack is removed, what should happen to the bucket? (RemovalPolicy.RETAIN is the default) | websiteIndexDocument | No | string | The index page of the site (index.html is the default) | websiteErrorDocument | No | string | The error page of the site (error.html is the default) | versioned | No | boolean | Should the artifacts be versioned (the default is yes) | bucketEncryption | No | BucketEncryption | Should the bucket be encrypted (Default is bucketEncryption.S3_MANAGED) | encryptionFactory | No | ConstructFactory | A factory to get encryption. Only used if the bucketEncryption is KMS
Managers are used to have a consolidated object that will control the CICD and Build process. This allows the same object to be passed to the CICD and APP setups. They allow for custom actions to be run during the IAC Setup, the Environment Setup, and when creating the stack. These managers will be passed to the CICD process.
Each stack above has a corresponding manager:
Managers can take a list of regions to work within to set up multi region deployment. For the client stack, however, CloudFront can only be deployed to 1 region. Therefore, make sure to supply only 1 region in the regions property for multi region deployments.
Conversely, for buckets used for replication, you should specify all of the regions except the main one. This will create the child buckets which you can then pass into the ClientStack.
In order to setup bucket replication, we need a role. The
IAM construct has a
s3ReplicationRole property which gets that role from SSM.
/dr/global/iam/s3-replication-role is the value that needs to be put into SSM, and should be an ARN for the role to use. By default, IAMFactory is used which will get the construct, but you can specify your own.