Skip to content

Commit bc65f50

Browse files
committed
Add main logic
1 parent 888e3b6 commit bc65f50

File tree

7 files changed

+123
-0
lines changed

7 files changed

+123
-0
lines changed

examples/complete/main.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module "codecommit" {
2+
3+
source = "lgallard/codecommit/aws"
4+
5+
repository_name = "codecommit-repo"
6+
description = "Git repositoriy in AWS"
7+
default_branch = "master"
8+
9+
triggers = [
10+
{
11+
name = "all"
12+
events = ["all"]
13+
destination_arn = "arn:aws:lambda:us-east-1:12345678910:function:lambda-all"
14+
},
15+
{
16+
name = "updateReference"
17+
events = ["updateReference"]
18+
destination_arn = "arn:aws:lambda:us-east-1:12345678910:function:lambda-updateReference"
19+
},
20+
]
21+
22+
tags = {
23+
Owner = "DevOps team"
24+
Environment = "dev"
25+
Terraform = true
26+
}
27+
28+
}

examples/complete/provider.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "aws" {
2+
profile = "default"
3+
region = "us-east-1"
4+
}

examples/simple/main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module "codecommit" {
2+
3+
source = "lgallard/codecommit/aws"
4+
5+
repository_name = "codecommit-repo"
6+
description = "Git repositoriy in AWS"
7+
8+
tags = {
9+
Owner = "DevOps team"
10+
Environment = "dev"
11+
Terraform = true
12+
}
13+
14+
}

examples/simple/provider.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "aws" {
2+
profile = "default"
3+
region = "us-east-1"
4+
}

main.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
resource "aws_codecommit_repository" "repo" {
2+
repository_name = var.repository_name
3+
description = var.description
4+
default_branch = var.default_branch
5+
6+
# Tags
7+
tags = var.tags
8+
9+
}
10+
11+
# Triggers
12+
resource "aws_codecommit_trigger" "triggers" {
13+
count = length(var.triggers)
14+
repository_name = aws_codecommit_repository.repo.repository_name
15+
16+
trigger {
17+
name = lookup(element(var.triggers, count.index), "name")
18+
events = lookup(element(var.triggers, count.index), "events")
19+
destination_arn = lookup(element(var.triggers, count.index), "destination_arn")
20+
}
21+
22+
}

outputs.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
output "repository_id" {
2+
description = "The ID of the repository"
3+
value = aws_codecommit_repository.repo.repository_id
4+
}
5+
6+
output "arn" {
7+
description = "The ARN of the repository"
8+
value = aws_codecommit_repository.repo.arn
9+
}
10+
11+
output "clone_url_http" {
12+
description = "The URL to use for cloning the repository over HTTPS."
13+
value = aws_codecommit_repository.repo.clone_url_http
14+
}
15+
16+
output "clone_url_ssh" {
17+
description = "The URL to use for cloning the repository over SSH."
18+
value = aws_codecommit_repository.repo.clone_url_ssh
19+
}

variables.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# General vars
2+
variable "repository_name" {
3+
description = "The name for the repository. This needs to be less than 100 characters."
4+
type = string
5+
}
6+
7+
variable "description" {
8+
description = "The description of the repository. This needs to be less than 1000 characters"
9+
type = string
10+
default = null
11+
}
12+
13+
variable "default_branch" {
14+
description = "The default branch of the repository. The branch specified here needs to exist."
15+
type = string
16+
default = null
17+
}
18+
19+
# Triggers
20+
variable "triggers" {
21+
description = "List of triggers"
22+
type = any
23+
default = []
24+
}
25+
26+
# Tags
27+
variable "tags" {
28+
description = "A mapping of tags to assign to the resource."
29+
type = map(string)
30+
default = {}
31+
}
32+

0 commit comments

Comments
 (0)