Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pepperize/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.
https://github.com/pepperize/cdk-terraform-state-backend
aws backend bucket cdk dynamodb lock s3 state terraform
Last synced: 3 months ago
JSON representation
This project provides a CDK construct bootstrapping an AWS account with a S3 Bucket and a DynamoDB table as terraform state backend.
- Host: GitHub
- URL: https://github.com/pepperize/cdk-terraform-state-backend
- Owner: pepperize
- License: mit
- Created: 2021-12-04T20:29:09.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-12T06:47:21.000Z (10 months ago)
- Last Synced: 2024-04-12T14:41:58.573Z (10 months ago)
- Topics: aws, backend, bucket, cdk, dynamodb, lock, s3, state, terraform
- Language: TypeScript
- Homepage:
- Size: 3.61 MB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://makeapullrequest.com)
[](https://github.com/pepperize/cdk-terraform-state-backend/blob/main/LICENSE)
[](https://www.npmjs.com/package/@pepperize/cdk-terraform-state-backend)
[](https://pypi.org/project/pepperize.cdk-terraform-state-backend/)
[](https://www.nuget.org/packages/Pepperize.CDK.TerraformStateBackend/)
[](https://s01.oss.sonatype.org/content/repositories/releases/com/pepperize/cdk-terraform-state-backend/)
[](https://github.com/pepperize/cdk-terraform-state-backend/actions/workflows/release.yml)
[](https://github.com/pepperize/cdk-terraform-state-backend/releases)# 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](https://www.terraform.io/docs/language/settings/backends/s3.html).
Terraform doesn't come shipped with a cli command bootstrapping the account for [State Storage and Locking](https://www.terraform.io/docs/language/state/backends.html)
like [AWS CDK](https://docs.aws.amazon.com/cdk/latest/guide/cli.html#cli-bootstrap) 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 TableSee [API.md](https://github.com/pepperize/cdk-terraform-state-backend/blob/main/API.md)
## Install
### TypeScript
```shell
npm install @pepperize/cdk-terraform-state-backend
```or
```shell
yarn add @pepperize/cdk-terraform-state-backend
```### Python
```shell
pip install pepperize.cdk-terraform-state-backend
```### C# / .Net
```
dotnet add package Pepperize.CDK.TerraformStateBackend
```### Java
```xml
com.pepperize
cdk-terraform-state-backend
${cdkTerraformStateBackend.version}```
## Example
```typescript
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",
});
``````hcl
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"
}
}
```See [Terraform S3 Example Configuration](https://www.terraform.io/docs/language/settings/backends/s3.html#example-configuration)