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-lib";
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"
}
}
Metadata
Release files for pepperize.cdk-terraform-state-backend 0.1.1205
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pepperize_cdk_terraform_state_backend-0.1.1205.tar.gz | 22.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pepperize_cdk_terraform_state_backend-0.1.1205-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.9 kB
Release files / pepperize_cdk_terraform_state_backend-0.1.1205.tar.gz
| Download URL | pepperize_cdk_terraform_state_backend-0.1.1205.tar.gz |
|---|---|
| Size | 22.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a808c0b226fddeee0fcfb108fe1533bfc6b43de3174de079d3e8da767d8daa7
|
|
BLAKE2b-256 checksum How to use checksums |
ccc93605c325a6a6ee9da3d09bd9159f3e5ec71c7b85a3d2bfca2eb3719c3351
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / pepperize_cdk_terraform_state_backend-0.1.1205-py3-none-any.whl
| Download URL | pepperize_cdk_terraform_state_backend-0.1.1205-py3-none-any.whl |
|---|---|
| Size | 23.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca5578ea0ccbda254dd3c49439a7f6a878cd544e79c41c170b5a89d5ce9e4890
|
|
BLAKE2b-256 checksum How to use checksums |
32b1a9a180a405a66ab129f135ed44bede19f3ae6ac4749602f9683044583bc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|