Skip to content

Commit b5caa56

Browse files
committed
inserting pipeline infos from an other terraform repo of mine
1 parent 411bb13 commit b5caa56

14 files changed

+173
-68
lines changed

.gitattributes

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Terraform Apply
2+
on: workflow_dispatch
3+
env:
4+
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
5+
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
6+
TF_VAR_aws_key_pub: ${{secrets.TF_VAR_aws_key_pub}}
7+
8+
jobs:
9+
terraform_apply:
10+
name: Terraform Apply
11+
runs-on: ubuntu:latest
12+
defaults:
13+
run:
14+
shell: bash
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Terraform Apply
19+
run: |
20+
terraform init
21+
terraform apply -auto-approve
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Terraform Destroy
2+
on: workflow_dispatch
3+
env:
4+
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
5+
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
6+
TF_VAR_aws_key_pub: ${{secrets.TF_VAR_aws_key_pub}}
7+
8+
jobs:
9+
terraform_destroy:
10+
name: Terraform Destroy
11+
runs-on: ubuntu:latest
12+
defaults:
13+
run:
14+
shell: bash
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Terraform Destroy
19+
run: |
20+
terraform init
21+
terraform destroy -auto-approve

.github/workflows/terraform-plan.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Terraform Plan
2+
on: push
3+
env:
4+
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
5+
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
6+
TF_VAR_aws_key_pub: ${{secrets.TF_VAR_aws_key_pub}}
7+
8+
jobs:
9+
terraform_plan:
10+
name: Terraform Plan
11+
runs-on: ubuntu:latest
12+
defaults:
13+
run:
14+
shell: bash
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Terraform Plan
19+
run: |
20+
terraform init
21+
terraform validate
22+
terraform plan

.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Crash log files
9+
crash.log
10+
crash.*.log
11+
12+
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
13+
# password, private keys, and other secrets. These should not be part of version
14+
# control as they are data points which are potentially sensitive and subject
15+
# to change depending on the environment.
16+
*.tfvars
17+
*.tfvars.json
18+
19+
# Ignore override files as they are usually used to override resources locally and so
20+
# are not checked in
21+
override.tf
22+
override.tf.json
23+
*_override.tf
24+
*_override.tf.json
25+
26+
# Ignore transient lock info files created by terraform apply
27+
.terraform.tfstate.lock.info
28+
29+
# Ignore dependency lock file created by Terraform to record provider versions
30+
.terraform.lock.hcl
31+
32+
# Include override files you do wish to add to version control using negated pattern
33+
# !example_override.tf
34+
35+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
36+
# example: *tfplan*
37+
*tfplan*
38+
plan.out
39+
40+
# Ignore CLI configuration files
41+
#.terraformrc
42+
#terraform.rc
43+
44+
# Ignore possible Keys
45+
aws-key
46+
aws-key*
47+
*.pub

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# test-branch
2-
1+
# Pipeline Terraform on GitHub Actions
2+
This repo has all the setup to it.

estilos/style.css

Lines changed: 0 additions & 17 deletions
This file was deleted.

index.html

Lines changed: 0 additions & 26 deletions
This file was deleted.

main.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
terraform {
2+
required_version = ">= 1.5.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "5.82.2"
8+
}
9+
}
10+
11+
backend "s3" {
12+
bucket = "juanborges-remote-state"
13+
key = "pipeline-github-actions/terraform.tfstate"
14+
region = "sa-east-1"
15+
}
16+
}
17+
18+
provider "aws" {
19+
region = "sa-east-1"
20+
21+
default_tags {
22+
tags = {
23+
owner = "juan"
24+
managed-by = "terraform"
25+
}
26+
}
27+
}
28+
29+
data "terraform_remote_state" "vpc" {
30+
backend = "s3"
31+
config = {
32+
bucket = "juanborges-remote-state"
33+
key = "aws-vpc/terraform.tfstate"
34+
region = "sa-east-1"
35+
}
36+
}

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "vm_aws_ip" {
2+
description = "VM's IP AWS"
3+
value = aws_instance.vm.public_ip
4+
}

pipeline_structure.jpg

1.3 MB
Loading

variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
variable "aws_key_pub" {
2+
description = "Key"
3+
type = string
4+
}

vm.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
resource "aws_key_pair" "key" {
2+
key_name = "aws_key_pipelines"
3+
public_key = var.aws_key_pub
4+
}
5+
6+
resource "aws_instance" "vm" {
7+
ami = "ami-015f3596bb2ef1aaa" #Ubuntu Server 24.04 LTS
8+
instance_type = "t3.micro"
9+
key_name = aws_key_pair.key.key_name
10+
subnet_id = data.terraform_remote_state.vpc.outputs.subnet_id
11+
vpc_security_group_ids = [data.terraform_remote_state.vpc.outputs.security_group_id]
12+
13+
tags = {
14+
Name = "vm-terraform"
15+
}
16+
}

0 commit comments

Comments
 (0)