File tree Expand file tree Collapse file tree 8 files changed +101
-0
lines changed Expand file tree Collapse file tree 8 files changed +101
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ name : CI/CD Infra AWS
3
+
4
+ on :
5
+ push :
6
+ branches :
7
+ - main
8
+
9
+ jobs :
10
+ terraform :
11
+ name : ' Subir Infra'
12
+ runs-on : ubuntu-latest
13
+ env :
14
+ TF_VAR_region : ${{ vars.REGION }}
15
+
16
+ steps :
17
+ - name : Checkout
18
+ uses : actions/checkout@v4
19
+
20
+ - name : Set up Terraform
21
+ uses : hashicorp/setup-terraform@v3
22
+ with :
23
+ terraform_version : 1.12.0
24
+
25
+ - name : Authenticate with AWS
26
+ uses : aws-actions/configure-aws-credentials@v4
27
+ with :
28
+ aws-access-key-id : ${{ secrets.ACCESS_KEY }}
29
+ aws-secret-access-key : ${{ secrets.SECRET_KEY }}
30
+ aws-region : ${{ vars.REGION }}
31
+
32
+ - name : Terraform Init
33
+ working-directory : infra
34
+ run : terraform init
35
+
36
+ - name : Terraform Validate
37
+ working-directory : infra
38
+ run : terraform validate
39
+
40
+ - name : Terraform Plan
41
+ working-directory : infra
42
+ run : terraform plan -var="region=${{ vars.REGION }}"
43
+
44
+ - name : Terraform Apply
45
+ if : github.ref == 'refs/heads/main'
46
+ working-directory : infra
47
+ run : terraform apply -auto-approve -var="region=${{ vars.REGION }}"
48
+
Original file line number Diff line number Diff line change
1
+
2
+ terraform {
3
+ backend "s3" {
4
+ bucket = " nome_bucket_terraform_states"
5
+ key = " infraestrutura/dev/terraform.tfstate"
6
+ region = " sa-east-1"
7
+ use_lockfile = true
8
+ encrypt = true
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+
2
+ provider "aws" {
3
+ region = var. region
4
+ }
5
+ # __________________________________________________________
6
+
7
+ module "s3" {
8
+ source = " ./modules/s3"
9
+ region = var. region
10
+ }
11
+ # __________________________________________________________
Original file line number Diff line number Diff line change
1
+
2
+ resource "aws_s3_bucket" "[nome_bucket]" {
3
+ bucket = local. nome_bucket
4
+ acl = " private"
5
+ force_destroy = false
6
+ versioning {
7
+ enabled = true
8
+ }
9
+ tags = {
10
+ Name = " MinhaTag"
11
+ Environment = local.environment
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ locals {
2
+ # BUCKET NAMES
3
+ # nome_bucket = "nome-unico-para-o-bucket"
4
+ # environment = "dev"
5
+ # ###################################################
6
+ }
Original file line number Diff line number Diff line change
1
+ # Valor preenchido automáticamente pelo GitHub Secrets
2
+ variable "region" {
3
+ description = " Região"
4
+ type = string
5
+ }
6
+ # __________________________________________________________
Original file line number Diff line number Diff line change
1
+
2
+ # Valor preenchido automáticamente pelo GitHub Secrets
3
+ variable "region" {
4
+ description = " Região"
5
+ type = string
6
+ }
7
+ # __________________________________________________________
You can’t perform that action at this time.
0 commit comments