Skip to content

Commit f50e4ad

Browse files
authored
Add github_webhooks_token and s3_bucket_force_destroy variables (#24)
1 parent 38c1896 commit f50e4ad

File tree

5 files changed

+57
-39
lines changed

5 files changed

+57
-39
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ In this example, we'll trigger anytime a new GitHub release is cut by setting th
7373

7474
```hcl
7575
module "ecs_release_pipeline" {
76-
source = "git::https://github.com/cloudposse/terraform-aws-ecs-codepipeline.git?ref=master"
77-
name = "app"
78-
namespace = "eg"
79-
stage = "staging"
80-
github_oauth_token = "xxxxxxxxxxxxxx"
81-
repo_owner = "cloudposse"
82-
repo_name = "example"
83-
branch = "master"
84-
service_name = "example"
85-
ecs_cluster_name = "example-ecs-cluster"
86-
privileged_mode = "true"
87-
github_webhook_events = ["release"]
88-
webhook_filter_json_path = "$.action"
76+
source = "git::https://github.com/cloudposse/terraform-aws-ecs-codepipeline.git?ref=master"
77+
name = "app"
78+
namespace = "eg"
79+
stage = "staging"
80+
github_oauth_token = "xxxxxxxxxxxxxx"
81+
repo_owner = "cloudposse"
82+
repo_name = "example"
83+
branch = "master"
84+
service_name = "example"
85+
ecs_cluster_name = "example-ecs-cluster"
86+
privileged_mode = "true"
87+
github_webhook_events = ["release"]
88+
webhook_filter_json_path = "$.action"
8989
webhook_filter_match_equals = "published"
9090
}
9191
```
@@ -160,8 +160,9 @@ Available targets:
160160
| ecs_cluster_name | ECS Cluster Name | string | - | yes |
161161
| enabled | Enable `CodePipeline` creation | string | `true` | no |
162162
| environment_variables | A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build. | list | `<list>` | no |
163-
| github_oauth_token | GitHub Oauth Token with permissions to access private repositories | string | - | yes |
164-
| github_webhook_events | A list of events which should trigger the webhook. See a list of [available events](https://developer.github.com/v3/activity/events/types/). | list | `<list>` | no |
163+
| github_oauth_token | GitHub OAuth Token with permissions to access private repositories | string | - | yes |
164+
| github_webhook_events | A list of events which should trigger the webhook. See a list of [available events](https://developer.github.com/v3/activity/events/types/) | list | `<list>` | no |
165+
| github_webhooks_token | GitHub OAuth Token with permissions to create webhooks. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable | string | `` | no |
165166
| image_repo_name | ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | string | `UNSET` | no |
166167
| image_tag | Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | string | `latest` | no |
167168
| name | Solution name, e.g. 'app' or 'jenkins' | string | `app` | no |
@@ -170,6 +171,7 @@ Available targets:
170171
| privileged_mode | If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images | string | `false` | no |
171172
| repo_name | GitHub repository name of the application to be built and deployed to ECS. | string | - | yes |
172173
| repo_owner | GitHub Organization or Username. | string | - | yes |
174+
| s3_bucket_force_destroy | A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error | string | `false` | no |
173175
| service_name | ECS Service Name | string | - | yes |
174176
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `default` | no |
175177
| tags | Additional tags (e.g. `map('BusinessUnit', 'XYZ')` | map | `<map>` | no |

README.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,19 @@ usage: |-
8383
8484
```hcl
8585
module "ecs_release_pipeline" {
86-
source = "git::https://github.com/cloudposse/terraform-aws-ecs-codepipeline.git?ref=master"
87-
name = "app"
88-
namespace = "eg"
89-
stage = "staging"
90-
github_oauth_token = "xxxxxxxxxxxxxx"
91-
repo_owner = "cloudposse"
92-
repo_name = "example"
93-
branch = "master"
94-
service_name = "example"
95-
ecs_cluster_name = "example-ecs-cluster"
96-
privileged_mode = "true"
97-
github_webhook_events = ["release"]
98-
webhook_filter_json_path = "$.action"
86+
source = "git::https://github.com/cloudposse/terraform-aws-ecs-codepipeline.git?ref=master"
87+
name = "app"
88+
namespace = "eg"
89+
stage = "staging"
90+
github_oauth_token = "xxxxxxxxxxxxxx"
91+
repo_owner = "cloudposse"
92+
repo_name = "example"
93+
branch = "master"
94+
service_name = "example"
95+
ecs_cluster_name = "example-ecs-cluster"
96+
privileged_mode = "true"
97+
github_webhook_events = ["release"]
98+
webhook_filter_json_path = "$.action"
9999
webhook_filter_match_equals = "published"
100100
}
101101
```

docs/terraform.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
| ecs_cluster_name | ECS Cluster Name | string | - | yes |
1616
| enabled | Enable `CodePipeline` creation | string | `true` | no |
1717
| environment_variables | A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build. | list | `<list>` | no |
18-
| github_oauth_token | GitHub Oauth Token with permissions to access private repositories | string | - | yes |
19-
| github_webhook_events | A list of events which should trigger the webhook. See a list of [available events](https://developer.github.com/v3/activity/events/types/). | list | `<list>` | no |
18+
| github_oauth_token | GitHub OAuth Token with permissions to access private repositories | string | - | yes |
19+
| github_webhook_events | A list of events which should trigger the webhook. See a list of [available events](https://developer.github.com/v3/activity/events/types/) | list | `<list>` | no |
20+
| github_webhooks_token | GitHub OAuth Token with permissions to create webhooks. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable | string | `` | no |
2021
| image_repo_name | ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | string | `UNSET` | no |
2122
| image_tag | Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | string | `latest` | no |
2223
| name | Solution name, e.g. 'app' or 'jenkins' | string | `app` | no |
@@ -25,6 +26,7 @@
2526
| privileged_mode | If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images | string | `false` | no |
2627
| repo_name | GitHub repository name of the application to be built and deployed to ECS. | string | - | yes |
2728
| repo_owner | GitHub Organization or Username. | string | - | yes |
29+
| s3_bucket_force_destroy | A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error | string | `false` | no |
2830
| service_name | ECS Service Name | string | - | yes |
2931
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `default` | no |
3032
| tags | Additional tags (e.g. `map('BusinessUnit', 'XYZ')` | map | `<map>` | no |

main.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ module "codepipeline_label" {
1313
}
1414

1515
resource "aws_s3_bucket" "default" {
16-
count = "${local.enabled ? 1 : 0}"
17-
bucket = "${module.codepipeline_label.id}"
18-
acl = "private"
19-
tags = "${module.codepipeline_label.tags}"
16+
count = "${local.enabled ? 1 : 0}"
17+
bucket = "${module.codepipeline_label.id}"
18+
acl = "private"
19+
force_destroy = "${var.s3_bucket_force_destroy}"
20+
tags = "${module.codepipeline_label.tags}"
2021
}
2122

2223
module "codepipeline_assume_label" {
@@ -171,7 +172,7 @@ data "aws_caller_identity" "default" {}
171172
data "aws_region" "default" {}
172173

173174
module "build" {
174-
source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=tags/0.12.1"
175+
source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=tags/0.16.0"
175176
enabled = "${var.enabled}"
176177
namespace = "${var.namespace}"
177178
name = "${var.name}"
@@ -306,11 +307,11 @@ resource "aws_codepipeline_webhook" "webhook" {
306307
}
307308

308309
module "github_webhooks" {
309-
source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=tags/0.3.0"
310+
source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=tags/0.4.0"
310311
enabled = "${local.enabled && var.webhook_enabled == "true" ? "true" : "false"}"
311312
github_organization = "${var.repo_owner}"
312313
github_repositories = ["${var.repo_name}"]
313-
github_token = "${var.github_oauth_token}"
314+
github_token = "${var.github_webhooks_token}"
314315
webhook_url = "${local.webhook_url}"
315316
webhook_secret = "${local.webhook_secret}"
316317
webhook_content_type = "json"

variables.tf

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,19 @@ variable "service_name" {
2929
}
3030

3131
variable "github_oauth_token" {
32-
description = "GitHub Oauth Token with permissions to access private repositories"
32+
type = "string"
33+
description = "GitHub OAuth Token with permissions to access private repositories"
34+
}
35+
36+
variable "github_webhooks_token" {
37+
type = "string"
38+
default = ""
39+
description = "GitHub OAuth Token with permissions to create webhooks. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable"
3340
}
3441

3542
variable "github_webhook_events" {
36-
description = "A list of events which should trigger the webhook. See a list of [available events](https://developer.github.com/v3/activity/events/types/)."
43+
description = "A list of events which should trigger the webhook. See a list of [available events](https://developer.github.com/v3/activity/events/types/)"
44+
type = "list"
3745
default = ["push"]
3846
}
3947

@@ -166,3 +174,8 @@ variable "webhook_filter_match_equals" {
166174
description = "The value to match on (e.g. refs/heads/{Branch})"
167175
default = "refs/heads/{Branch}"
168176
}
177+
178+
variable "s3_bucket_force_destroy" {
179+
description = "A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error"
180+
default = false
181+
}

0 commit comments

Comments
 (0)