hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.79k stars 9.14k forks source link

[Bug]: Terraform resource `aws_codecommit_repository` argument `default_branch` is not adding default branch as expected #30673

Open reshma-ayyappan opened 1 year ago

reshma-ayyappan commented 1 year ago

Terraform Core Version

0.14.5

AWS Provider Version

~> 4.0

Affected Resource(s)

aws_codecommit_repository

Expected Behavior

As per the documentation https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codecommit_repository#attributes-reference , assume the optional parameter default_branch will add a branch to the repository

Actual Behavior

No default branch is not being added to repository as expected

Relevant Error/Panic Output Snippet

# aws_codecommit_repository.codecommit_repo will be created
  + resource "aws_codecommit_repository" "codecommit_repo" {
      + arn             = (known after apply)
      + clone_url_http  = (known after apply)
      + clone_url_ssh   = (known after apply)
      + default_branch  = "master"
      + description     = "This is the Sample App Repository, created from morpheus"
      + id              = (known after apply)
      + repository_id   = (known after apply)
      + repository_name = "sample-repo"
      + tags_all        = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Terraform Configuration Files

main.tf :

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
    }
  }
}

# Configure the AWS Provider
provider "aws" {
  region = var.aws_region
  access_key = var.access_key
  secret_key = var.secret_key
}

resource "aws_codecommit_repository" "codecommit_repo" {
  repository_name = "sample-repo"
  description     = "This is the Sample App Repository, created from morpheus"
  default_branch = "master"
}

Steps to Reproduce

Create terraform using code under 'Terraform Configuration Files' section and run terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

espadrille commented 10 months ago

The default branch property of the repository is set correctly in CodeCommit but it is not registered in terraform.tfstate as when you "terraform apply" a second time, it shows a change on the default_branch property. Say "yes" on the second apply, and it is set correctly.