diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 6e7df42c1..3743eaa26 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -1,5 +1,4 @@ name: "Terraform" - on: push: branches: @@ -71,6 +70,7 @@ jobs: if: steps.plan.outcome == 'failure' run: exit 1 + - name: Terraform Apply if: github.ref == 'refs/heads/main' && github.event_name == 'push' run: terraform apply -auto-approve diff --git a/main.tf b/main.tf index e1d1b8045..9f24dead1 100644 --- a/main.tf +++ b/main.tf @@ -12,21 +12,21 @@ terraform { required_version = "~> 1.0" backend "remote" { - organization = "REPLACE_ME" + organization = "ACG-Terraform-pradip" workspaces { - name = "REPLACE_ME" + name = "demo-github-action" } } } + provider "aws" { region = "us-east-1" } - resource "random_pet" "sg" {} resource "aws_instance" "web" { @@ -41,6 +41,17 @@ resource "aws_instance" "web" { EOF } +resource "aws_instance" "app_server" { + ami = "ami-09e67e426f25ce0d7" + vpc_security_group_ids = [aws_security_group.web-sg.id] + instance_type = "t2.micro" + + tags = { + Name = "ExampleAppServerInstance" + } +} + + resource "aws_security_group" "web-sg" { name = "${random_pet.sg.id}-sg" ingress {