Skip to content

Commit

Permalink
T12 update (#1)
Browse files Browse the repository at this point in the history
* Fixes pipeline s3 reference.
* Additonal index fixes.
* Updates label module.
* Default to *
  • Loading branch information
dlz21 authored Sep 29, 2019
1 parent 4b054b0 commit 991cf59
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
30 changes: 14 additions & 16 deletions bg.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
resource "aws_iam_role_policy_attachment" "ecs_limited" {
role = "${aws_iam_role.default.id}"
role = "${element(concat(aws_iam_role.default.*.id, list("")), 0)}"
policy_arn = "${aws_iam_policy.ecs_limited.arn}"
}

module "codepipeline_ecs_limited_policy_label" {
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.2.1"
attributes = ["${compact(concat(var.attributes, list("codepipeline", "ecs", "limited")))}"]
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.4.0"
attributes = "${compact(concat(var.attributes, list("codepipeline", "ecs", "limited")))}"
delimiter = "${var.delimiter}"
name = "${var.name}"
namespace = "${var.namespace}"
Expand Down Expand Up @@ -36,7 +36,7 @@ data "aws_iam_policy_document" "ecs_limited" {

statement {
actions = ["sns:publish"]
resources = ["${var.code_deploy_sns_topic_arn == "" ? "" : var.code_deploy_sns_topic_arn}", "arn:aws:sns:*:*:CodeDeployTopic_*"]
resources = ["${var.code_deploy_sns_topic_arn == "" ? "*" : var.code_deploy_sns_topic_arn}", "arn:aws:sns:*:*:CodeDeployTopic_*"]
effect = "Allow"
}

Expand All @@ -58,7 +58,7 @@ data "aws_iam_policy_document" "ecs_limited" {
"lambda:InvokeFunction"
]

resources = ["${var.code_deploy_lambda_hook_arns == "" ? "" : var.code_deploy_lambda_hook_arns}"]
resources = ["${var.code_deploy_lambda_hook_arns == "" ? "*" : var.code_deploy_lambda_hook_arns}"]
effect = "Allow"
}

Expand All @@ -83,15 +83,13 @@ data "aws_iam_policy_document" "ecs_limited" {
statement {
actions = ["iam:PassRole"]

resources = [
"*"
]
resources = ["*"]
}
}

module "codepipeline_codedeploy_policy_label" {
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.2.1"
attributes = ["${compact(concat(var.attributes, list("codepipeline", "codedeploy")))}"]
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.4.0"
attributes = "${compact(concat(var.attributes, list("codepipeline", "codedeploy")))}"
delimiter = "${var.delimiter}"
name = "${var.name}"
namespace = "${var.namespace}"
Expand All @@ -100,7 +98,7 @@ module "codepipeline_codedeploy_policy_label" {
}

resource "aws_iam_role_policy_attachment" "deploy" {
role = "${aws_iam_role.default.id}"
role = "${element(concat(aws_iam_role.default.*.id, list("")), 0)}"
policy_arn = "${aws_iam_policy.deploy.arn}"
}

Expand Down Expand Up @@ -133,10 +131,10 @@ data "aws_iam_policy_document" "deploy" {
resource "aws_codepipeline" "source_build_deploy_bg" {
count = "${local.enabled ? 1 : 0}"
name = "${module.codepipeline_label.id}"
role_arn = "${aws_iam_role.default.arn}"
role_arn = "${element(concat(aws_iam_role.default.*.arn, list("")), 0)}"

artifact_store {
location = "${aws_s3_bucket.default.bucket}"
location = "${element(concat(aws_s3_bucket.default.*.bucket, list("")), 0)}"
type = "S3"
}

Expand All @@ -160,7 +158,7 @@ resource "aws_codepipeline" "source_build_deploy_bg" {
version = "1"
output_artifacts = ["code"]

configuration {
configuration = {
OAuthToken = "${var.github_oauth_token}"
Owner = "${var.repo_owner}"
Repo = "${var.repo_name}"
Expand All @@ -183,7 +181,7 @@ resource "aws_codepipeline" "source_build_deploy_bg" {
input_artifacts = ["code"]
output_artifacts = ["task"]

configuration {
configuration = {
ProjectName = "${module.build.project_name}"
}
}
Expand All @@ -200,7 +198,7 @@ resource "aws_codepipeline" "source_build_deploy_bg" {
input_artifacts = ["task"]
version = "1"

configuration {
configuration = {
ApplicationName = "${var.code_deploy_application_name}"
DeploymentGroupName = "${var.code_deploy_deployment_group_name}"
TaskDefinitionTemplateArtifact = "task"
Expand Down
42 changes: 21 additions & 21 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ locals {
}

module "codepipeline_label" {
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.2.1"
attributes = ["${compact(concat(var.attributes, list("codepipeline")))}"]
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.4.0"
attributes = "${compact(concat(var.attributes, list("codepipeline")))}"
delimiter = "${var.delimiter}"
name = "${var.name}"
namespace = "${var.namespace}"
Expand Down Expand Up @@ -51,8 +51,8 @@ resource "aws_s3_bucket" "default" {
}

module "codepipeline_assume_label" {
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.2.1"
attributes = ["${compact(concat(var.attributes, list("codepipeline", "assume")))}"]
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.4.0"
attributes = "${compact(concat(var.attributes, list("codepipeline", "assume")))}"
delimiter = "${var.delimiter}"
name = "${var.name}"
namespace = "${var.namespace}"
Expand Down Expand Up @@ -85,8 +85,8 @@ data "aws_iam_policy_document" "assume" {

resource "aws_iam_role_policy_attachment" "default" {
count = "${local.enabled ? 1 : 0}"
role = "${aws_iam_role.default.id}"
policy_arn = "${aws_iam_policy.default.arn}"
role = "${element(concat(aws_iam_role.default.*.id, list("")), 0)}"
policy_arn = "${element(concat(aws_iam_policy.default.*.arn, list("")), 0)}"
}

resource "aws_iam_policy" "default" {
Expand Down Expand Up @@ -120,13 +120,13 @@ data "aws_iam_policy_document" "default" {

resource "aws_iam_role_policy_attachment" "s3" {
count = "${local.enabled ? 1 : 0}"
role = "${aws_iam_role.default.id}"
policy_arn = "${aws_iam_policy.s3.arn}"
role = "${element(concat(aws_iam_role.default.*.id, list("")), 0)}"
policy_arn = "${element(concat(aws_iam_policy.s3.*.arn, list("")), 0)}"
}

module "codepipeline_s3_policy_label" {
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.2.1"
attributes = ["${compact(concat(var.attributes, list("codepipeline", "s3")))}"]
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.4.0"
attributes = "${compact(concat(var.attributes, list("codepipeline", "s3")))}"
delimiter = "${var.delimiter}"
name = "${var.name}"
namespace = "${var.namespace}"
Expand All @@ -137,7 +137,7 @@ module "codepipeline_s3_policy_label" {
resource "aws_iam_policy" "s3" {
count = "${local.enabled ? 1 : 0}"
name = "${module.codepipeline_s3_policy_label.id}"
policy = "${data.aws_iam_policy_document.s3.json}"
policy = "${element(concat(data.aws_iam_policy_document.s3.*.json, list("")), 0)}"
}

data "aws_iam_policy_document" "s3" {
Expand All @@ -154,8 +154,8 @@ data "aws_iam_policy_document" "s3" {
]

resources = [
"${aws_s3_bucket.default.arn}",
"${aws_s3_bucket.default.arn}/*",
"${element(concat(aws_s3_bucket.default.*.arn, list("")), 0)}",
"${format("%s/*", element(concat(aws_s3_bucket.default.*.arn, list("")), 0))}"
]

effect = "Allow"
Expand All @@ -164,13 +164,13 @@ data "aws_iam_policy_document" "s3" {

resource "aws_iam_role_policy_attachment" "codebuild" {
count = "${local.enabled ? 1 : 0}"
role = "${aws_iam_role.default.id}"
policy_arn = "${aws_iam_policy.codebuild.arn}"
role = "${element(concat(aws_iam_role.default.*.id, list("")), 0)}"
policy_arn = "${element(concat(aws_iam_policy.codebuild.*.arn, list("")), 0)}"
}

module "codebuild_label" {
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.2.1"
attributes = ["${compact(concat(var.attributes, list("codebuild")))}"]
source = "github.com/cloudposse/terraform-terraform-label.git?ref=0.4.0"
attributes = "${compact(concat(var.attributes, list("codebuild")))}"
delimiter = "${var.delimiter}"
name = "${var.name}"
namespace = "${var.namespace}"
Expand Down Expand Up @@ -202,7 +202,7 @@ data "aws_caller_identity" "default" {}
data "aws_region" "default" {}

module "build" {
source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=tags/0.16.0"
source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=tags/0.17.0"
enabled = "${var.enabled}"
namespace = "${var.namespace}"
name = "${var.name}"
Expand All @@ -227,7 +227,7 @@ module "build" {
resource "aws_iam_role_policy_attachment" "codebuild_s3" {
count = "${local.enabled ? 1 : 0}"
role = "${module.build.role_id}"
policy_arn = "${aws_iam_policy.s3.arn}"
policy_arn = "${element(concat(aws_iam_policy.s3.*.arn, list("")), 0)}"
}

resource "random_string" "webhook_secret" {
Expand Down Expand Up @@ -261,13 +261,13 @@ resource "aws_codepipeline_webhook" "webhook" {
}

module "github_webhooks" {
source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=tags/0.4.0"
source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=terraform-0.12"
enabled = "${local.enabled && var.webhook_enabled == "true" ? "true" : "false"}"
github_organization = "${var.repo_owner}"
github_repositories = ["${var.repo_name}"]
github_token = "${var.github_webhooks_token}"
webhook_url = "${local.webhook_url}"
webhook_secret = "${local.webhook_secret}"
webhook_content_type = "json"
events = ["${var.github_webhook_events}"]
events = "${var.github_webhook_events}"
}

0 comments on commit 991cf59

Please sign in to comment.