AWS is a project with many proof of concept modules...
Note
if you change scala code, you need to rerun main
sbt vpc/runMain io.github.mvillafuertem.Main2
- Comment S3Backend resource which is inside Terraform.scala
// private val _: S3Backend = S3Backend.Builder
// .create(self)
// .bucket(configuration.bucket)
// .key("backend/terraform.tfstate")
// .region("eu-west-2")
// .dynamodbTable(configuration.dynamodbTable)
// .encrypt(true)
// .profile("gbgdev")
// .build()
- Create backend stack
cd modules/vpc/src/main/resources/stacks/mvillafuertem-backend
terraform apply
...
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
....
- Uncomment S3Backend resource which is inside Terraform.scala
terraform apply
│ Error: Backend initialization required: please run "terraform init"
│
│ Reason: Backend type changed from "local" to "s3"
...
- Run terraform init again
terraform init -migrate-state
Initializing the backend...
Terraform detected that the backend type changed from "local" to "s3".
Do you want to copy existing state to the new backend?
...
Enter a value: yes
- Check everything is ok
terraform plan
No changes. Your infrastructure matches the configuration.
terraform init -var="profile=myprofile"
terraform init -backend-config="profile=myprofile"