- Install AWS CLI
- Create an AWS profile in your local AWS configuration (
~/.aws/*
) with access keys of a user with right permissions for provisioning resources mentioned in Components section below.
$ aws configure --profile orion
AWS Access Key ID [None]: AK*********E
AWS Secret Access Key [None]: je7M***************EY
Default region name [None]: eu-west-1
Default output format [None]: text
- set aws cli to use
orion
AWS profile:
export AWS_PROFILE=orion
- Create a bucket:
aws s3api create-bucket --bucket orion-tf-state-<org> --region eu-west-1 --create-bucket-configuration LocationConstraint=eu-west-1 --profile=orion
Where is the name of the organisation you are provisioning (remember that S3 buckets are in the global name space).
- Enable versioning on the bucket:
aws s3api put-bucket-versioning --bucket orion-tf-state-<org> --versioning-configuration Status=Enabled --profile=orion
- Install Terraform
- Init Terraform:
terraform init -backend-config="bucket=orion-tf-state-<org>" -backend-config="key=terraform.tfstate" -backend-config="region=eu-west-1" -backend-config="profile=orion"
- Rename
sample.input-[env].tfvars
toinput-[env].tfvars
and fill in missing secrets: - Run plan:
terraform plan -var-file input-[env].tfvars
- Provision the infrastructure:
terraform apply -var-file input-[env].tfvars