Terraform S3 Backend
I love to grease knots and bolts of SDLC, nurture the underlying infra, rightly automate, monitor systems and enable the dev teams to achieve more with less.
Search for a command to run...
I love to grease knots and bolts of SDLC, nurture the underlying infra, rightly automate, monitor systems and enable the dev teams to achieve more with less.
No comments yet. Be the first to comment.
Command Cheat sheet https://helm.sh/docs/intro/cheatsheet/ Add/Search/Install/Uninstall repo helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update bitnami helm repo list helm install wordpress bitnami/wordpress helm list helm sta...

https://kops.sigs.k8s.io/getting_started/aws/ Pre-requisite DOMAIN=kops.balmanrawat.com.np aws route53 create-hosted-zone \ --name ${DOMAIN} \ --caller-reference kops-expriment ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --ou...

Containers have become the default way to package, ship, and run modern applications. They make deployments repeatable, portable, and scalable. But containers are not magic security boxes. A container

Details: https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ Pre-requisite A compatible Linux host. Verify the MAC address and product_uuid are unique for every node. Kubernetes uses these values to uniquely ident...

Docs Link1 Link2 Install Session Manger Plugin AWS SSM Proxy. Optional Start basic ssh connection aws ssm start-session \ --target i-askfsa8asld Port Forwarding aws ssm start-session \ --target i-00e68c055d1c0b087 \ --document-na...


Hashicorp terraform supports multiple backends out of which S3 is one of the them. If you are an AWS customer and looking forward to stay within AWS boundary then s3 backend is the right choice for you. Find more details
S3Backend supports
State storage with s3 bucketHistory of state files with s3 bucket versioning (recommended)State locking with Dynamodb table(recommended)We just need to create a S3 bucket and a dynamodb table with the configuration defined by the s3backend. You can create the resources by using the below commands or manually following the steps defined below:
git clone git@github.com:BalmanRawat/terraform-s3backend.git
cd terraform-s3backend
make init
## update the variables.tf file if necessary
make apply
S3 Bucket Requirements
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::backend-bucket"
},
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
"Resource": "arn:aws:s3:::backend-bucket/path/to/my/key"
}
]
}
DynamoDB Table Requirements
DynamoDB table is optional but terraform will not be able to lock the state file.
LockID with type of String{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:DeleteItem"
],
"Resource": "arn:aws:dynamodb:*:*:table/backend-table"
}
]
}
To make use of the backend we need to configure backend in the terraform settings.
Example configuration. Find all the possible configuration here
terraform {
backend "s3" {
bucket = "<bucket-name>"
key = "<bucket-key-for-terraform-state-file"
region = "<aws-region>"
dynamodb_table = "<dynamodb-table>"
}
}
OR
make use of the examples in the repository.
git clone git@github.com:BalmanRawat/terraform-s3backend.git
cd terraform-s3backend/examples
make init
## replace the bucket-name, key, region, dynamodb_table with your bucket
make apply
Once we apply the change we should be able to see similar changes in the bucket and table as shown below:


All done. Remember to run terraform destory once you are done with the experiment.
-> until next time.