Skip to content

Code Commit

AWS Codecommit is a managed Git service with your AWS account. It supports Git features such as PR's and integrates with IAM.

You can use an existing module or write your own.

This module combines IAM groups with Cloudwatch events and SNS to trigger on every change and can be set to branch protect a given branch.

The core resource is aws_codecommit_repository.repo.tf

resource "aws_codecommit_repository" "repo" {
  repository_name = var.repository_name
  description     = var.repository_name
  default_branch  = var.default_branch
}

Create a new Respository from scratch

Create a new folder aws_codecommit

Add a module reference module.codecommit.tf

module "codecommit" {
  source  = "JamesWoolfenden/codecommit/aws"
  version = "0.2.53"
  repository_name = var.repository_name
}

Add your variables.tf with:

variable "repository_name" {
  type        = string
  description = "The name of your GIT repository"
}

Add these additional outputs to a outputs.tf:

output "clone_url_https" {
  value = module.codecommit.clone_url_https
}

output "clone_url_ssh" {
  value = module.codecommit.clone_url_ssh
}

And a property file with main.auto.tfvars

repository_name = "Valyria"

Put this all together with:

terraform init
terraform apply

Note

https://registry.terraform.io/modules/JamesWoolfenden/codecommit/aws/0.2.53