Terraform Cloud with remoted Backend connected to github VCS

Viewed 34

I have terraform cloud as a backend integrated with github used to provision aws resources. When I change my terraform code and create a pull request, Terraform generates a plan.

Here is the structure of terraform.

Modules
   alb
      modulealb.tf
Environments
   dev
      alb.tf

In dev folder is my working directory for Terraform cloud workspace.

Issue is, when I make some changes in modulealb.tf and commit my changes to github, Terraform cloud does not recognize those changes and infrastructure updates are not planned.

How I can make Terraform cloud recognize my changes in modules.

From Vscode, I tried

terraform init -upgrade
terraform get -update

Modules are initialzed and I commit my changes to github but still those module changes are not being picked up by terraform cloud.

Please point me in the right direction. Thank you.

Edit: To provide more context, I am working with changing my security group and route table modules.

My previous modules are "aws_route_table" with inline route.

resource "aws_route_table" "public_rt" {
  vpc_id = aws_vpc.main.id

   route {
     cidr_block = var.aws_route_table_public_rt_cidr_block
     gateway_id = aws_internet_gateway.main.id
   }
}

Now I commented that one inline route and did a pull request, terraform plan don't have any changes. Still I applied those changes and added a new module "aws_route" to include one route.

resource "aws_route" "aws_internet_gateway" {
  route_table_id            = aws_route_table.public_rt.id
  destination_cidr_block    = var.aws_route_table_public_rt_cidr_block
  gateway_id = aws_internet_gateway.main.id
}

I created a pull request and terraform apply errored as that route is already existing and cannot create a duplicate route. So I deleted routes from AWS console and apply terraform, it is successful and added those changes.

In the similar way I only had "aws_security_group" with one inline ingress and one inline egress block. Now I added a new module by commenting out those inline blocks and deleted existing rules in AWS console, Terraform apply created those security group rules.

Hopefully I have done everything right, but the main issue here is when I have these "aws_security_group", "aws_route_table" modules with inline blocks when I comment those inline blocks terraform plan don't have any changes

Looking at my state file, For "aws_security_group" Inline ingress and egress and deleted/removed by terraform.

0 Answers
Related