This project provides a CDK construct bootstrapping an AWS account with a S3 Bucket and a DynamoDB table as terraform state backend.
Project description
AWS CDK Terraform state backend
This project provides a CDK construct bootstrapping an AWS account with a S3 Bucket and a DynamoDB table as Terraform state backend.
Terraform doesn't come shipped with a cli command bootstrapping the account for State Storage and Locking
like AWS CDK provides with cdk bootstrap
.
While bootstrapping the AWS Organization and Accounts this construct may be used to create:
- S3 Bucket with blocked public access, versioned, encrypted by SSE-S3
- DynamoDB Table with pay per request, continuous backups using point-in-time recovery, encrypted by AWS owned key
- IAM Policy with read/write access to the created S3 Bucket and DynamoDB Table
See API.md
Install
TypeScript
npm install @pepperize/cdk-terraform-state-backend
or
yarn add @pepperize/cdk-terraform-state-backend
Python
pip install pepperize.cdk-terraform-state-backend
C# / .Net
dotnet add package Pepperize.CDK.TerraformStateBackend
Java
<dependency>
<groupId>com.pepperize</groupId>
<artifactId>cdk-terraform-state-backend</artifactId>
<version>${cdkTerraformStateBackend.version}</version>
</dependency>
Example
import { App, Stack } from "@aws-cdk/core";
import { TerraformStateBackend } from "@pepperize/cdk-terraform-state-backend";
const app = new App();
const stack = new Stack(app, "stack", {
env: {
account: "123456789012",
region: "us-east-1",
},
});
// When
new TerraformStateBackend(stack, "TerraformStateBackend", {
bucketName: "terraform-state-backend",
tableName: "terraform-state-backend",
});
terraform {
backend "s3" {
bucket = "terraform-state-backend-123456789012-us-east-1"
dynamodb_table = "terraform-state-backend-123456789012"
key = "path/to/my/key"
region = "us-east-1"
}
}
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
Close
Hashes for pepperize.cdk-terraform-state-backend-0.1.100.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22ec65bb9102b62712084160e715a75f5eca4a8be50c1d6d157834e85c78a9c8 |
|
MD5 | f57ce9a42242e6eb3214d5752b0ce9b0 |
|
BLAKE2b-256 | 89a07d1bd5d9890f2baea05840fa61a594610c5c6463d351e2d647cdab75797e |
Close
Hashes for pepperize.cdk_terraform_state_backend-0.1.100-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a375d92bd6b2e917ba54b0725fe03d775c54d017d40bb9dafaa0b3d8b19758f1 |
|
MD5 | d86c1f1d09d88fca28bc5488426aa73d |
|
BLAKE2b-256 | 73312f5c6954d38133238be9ed080763d2ca19f986059c4377ba3caf436d05e5 |