-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(instances): add bootstrap and persist terraform-state on S3 e Dy…
…namo
- Loading branch information
1 parent
110e510
commit aaf989d
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## Instancias | ||
|
||
Tecnologia: terraform | ||
|
||
### Como executar a infraestrutura | ||
|
||
O estado do terraform está sendo compartilhado no S3 com gerenciamento de lock em uma tabela no DynamoDB. | ||
|
||
Se o bucket configurado `bonde-terraform-up-and-running-state` não existir na lista de buckets da sua conta Amazon (região: us-east-1), você deve executar os seguintes comandos na pasta `instances/boostrap`: | ||
|
||
```bash | ||
terraform init | ||
terraform plan | ||
terraform init -auto-approve | ||
``` | ||
|
||
Essa sequência de comandos acima irá criar a infraestrutura não persistente responsável por cuidar do estado da nossa infraestrutura persistente. | ||
|
||
#### Executando a infraestrutura persistente | ||
|
||
|
||
|
||
## Sites | ||
|
||
|
||
## TODO | ||
|
||
- Persistir o estado no S3 | ||
- Criar fluxo de trabalho para publicação automatizada no Github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
resource "aws_s3_bucket" "terraform_state" { | ||
bucket = "bonde-terraform-up-and-running-state" | ||
|
||
# Prevent accidental deletion of this S3 bucket | ||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket_versioning" "enabled" { | ||
bucket = aws_s3_bucket.terraform_state.id | ||
versioning_configuration { | ||
status = "Enabled" | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket_server_side_encryption_configuration" "default" { | ||
bucket = aws_s3_bucket.terraform_state.id | ||
|
||
rule { | ||
apply_server_side_encryption_by_default { | ||
sse_algorithm = "AES256" | ||
} | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket_public_access_block" "public_access" { | ||
bucket = aws_s3_bucket.terraform_state.id | ||
block_public_acls = true | ||
block_public_policy = true | ||
ignore_public_acls = true | ||
restrict_public_buckets = true | ||
} | ||
|
||
resource "aws_dynamodb_table" "terraform_locks" { | ||
name = "terraform-up-and-running-locks" | ||
billing_mode = "PAY_PER_REQUEST" | ||
hash_key = "LockID" | ||
|
||
attribute { | ||
name = "LockID" | ||
type = "S" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters