Skip to content

Commit

Permalink
Merge pull request #13 from globeandmail/2.0
Browse files Browse the repository at this point in the history
v2.0 - requires AWS provider 4.0
  • Loading branch information
tgam-smickeler authored Apr 19, 2022
2 parents 737f764 + 7b2359e commit dad4287
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Creates a codebuild project and S3 artifact bucket to be used with codepipeline.

```hcl
module "codebuild_project" {
source = "github.com/globeandmail/aws-codebuild-project?ref=1.9"
source = "github.com/globeandmail/aws-codebuild-project?ref=2.0"
name = var.name
deploy_type = var.deploy_type
Expand Down
35 changes: 21 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,35 @@ locals {
resource "aws_s3_bucket" "artifact" {
# S3 bucket cannot be longer than 63 characters
bucket = lower(trimsuffix(substr("codepipeline-${local.aws_region}-${local.account_id}-${var.name}", 0, 63), "-"))
acl = "private"

lifecycle_rule {
enabled = true
expiration {
days = 90
}
}


tags = var.tags
}

resource "aws_s3_bucket_public_access_block" "artifact" {
count = var.s3_block_public_access ? 1 : 0
bucket = aws_s3_bucket.artifact.id

block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}

resource "aws_s3_bucket_acl" "artifact" {
bucket = aws_s3_bucket.artifact.id
acl = "private"
}

resource "aws_s3_bucket_lifecycle_configuration" "artifact" {
bucket = aws_s3_bucket.artifact.id
rule {
id = "expire"
status = "Enabled"
expiration {
days = 90
}
}
}

resource "aws_cloudwatch_log_group" "group" {
name = "/aws/codebuild/${var.name}"
Expand Down Expand Up @@ -214,7 +221,7 @@ resource "aws_codebuild_project" "project" {
content {
name = "REPO_ACCESS_GITHUB_TOKEN_SECRETS_ID"
value = var.svcs_account_github_token_aws_secret_arn
type = "SECRETS_MANAGER"
type = "SECRETS_MANAGER"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ variable "privileged_mode" {

}
variable "tags" {
type = map
type = map(any)
description = "(Optional) A mapping of tags to assign to the resource"
default = {}
}
Expand Down Expand Up @@ -91,7 +91,7 @@ variable "svcs_account_github_token_aws_kms_cmk_arn" {
}

variable "s3_block_public_access" {
type = bool
type = bool
description = "(Optional) Enable the S3 block public access setting for the artifact bucket."
default = false
default = false
}
4 changes: 4 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
terraform {
required_version = ">= 0.12"

required_providers {
aws = "~> 4.0"
}
}

0 comments on commit dad4287

Please sign in to comment.