Skip to content

Commit 38ecf6c

Browse files
authored
feat: initial implementation (#1)
1 parent 3efd1fb commit 38ecf6c

15 files changed

+1566
-194
lines changed

README.md

+95-59
Large diffs are not rendered by default.

README.yaml

+51-44
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,71 @@
1-
---
21
#
32
# This is the canonical configuration for the `README.md`
43
# Run `make readme` to rebuild the `README.md`
54
#
65

76
# Name of this project
8-
name: terraform-example-module
7+
name: terraform-aws-code-deploy
98

109
# Logo for this project
1110
#logo: docs/logo.png
1211

1312
# License of this project
14-
license: "APACHE2"
13+
license: APACHE2
1514

1615
# Copyrights
1716
copyrights:
18-
- name: "Cloud Posse, LLC"
19-
url: "https://cloudposse.com"
20-
year: "2020"
17+
- name: Cloud Posse, LLC
18+
url: https://cloudposse.com
19+
year: '2020'
2120

2221
# Canonical GitHub repo
23-
github_repo: cloudposse/terraform-example-module
22+
github_repo: cloudposse/terraform-aws-code-deploy
2423

2524
# Badges to display
2625
badges:
27-
- name: "Latest Release"
28-
image: "https://img.shields.io/github/release/cloudposse/terraform-example-module.svg"
29-
url: "https://github.com/cloudposse/terraform-example-module/releases/latest"
30-
- name: "Slack Community"
31-
image: "https://slack.cloudposse.com/badge.svg"
32-
url: "https://slack.cloudposse.com"
33-
- name: "Discourse Forum"
34-
image: "https://img.shields.io/discourse/https/ask.sweetops.com/posts.svg"
35-
url: "https://ask.sweetops.com/"
26+
- name: Latest Release
27+
image: https://img.shields.io/github/release/cloudposse/terraform-aws-code-deploy.svg
28+
url: https://github.com/cloudposse/terraform-aws-code-deploy/releases/latest
29+
- name: Slack Community
30+
image: https://slack.cloudposse.com/badge.svg
31+
url: https://slack.cloudposse.com
32+
- name: Discourse Forum
33+
image: https://img.shields.io/discourse/https/ask.sweetops.com/posts.svg
34+
url: https://ask.sweetops.com/
3635

3736
# List any related terraform modules that this module may be used with or that this module depends on.
3837
related:
39-
- name: "terraform-null-label"
40-
description: "Terraform module designed to generate consistent names and tags for resources. Use terraform-null-label to implement a strict naming convention."
41-
url: "https://github.com/cloudposse/terraform-null-label"
42-
43-
# List any resources helpful for someone to get started. For example, link to the hashicorp documentation or AWS documentation.
38+
- name: terraform-aws-sns-topic
39+
description: Terraform Module to Provide an Amazon Simple Notification Service (SNS)
40+
url: https://github.com/cloudposse/terraform-aws-sns-topic
41+
- name: terraform-null-label
42+
description: Terraform Module to define a consistent naming convention by (namespace,
43+
stage, name, [attributes])
44+
url: https://github.com/cloudposse/terraform-null-label
45+
- name: terraform-aws-codebuild
46+
description: Terraform Module to easily leverage AWS CodeBuild for Continuous Integration
47+
url: https://github.com/cloudposse/terraform-aws-codebuild
48+
- name: terraform-aws-codepipeline-codedeploy
49+
description: Terraform module that generates an AWS Codepipeline, and deploys via
50+
CodeDeploy
51+
url: https://github.com/cloudposse/terraform-aws-codepipeline-codedeploy
52+
- name: terraform-aws-codefresh-backing-services
53+
description: Terraform module to provision AWS backing services necessary to run
54+
Codefresh Enterprise
55+
url: https://github.com/cloudposse/terraform-aws-codefresh-backing-services
56+
- name: terraform-aws-code-deploy
57+
description:
58+
url: https://github.com/cloudposse/terraform-aws-code-deploy
4459
references:
45-
- name: "Terraform Standard Module Structure"
46-
description: "HashiCorp's standard module structure is a file and directory layout we recommend for reusable modules distributed in separate repositories."
47-
url: "https://www.terraform.io/docs/modules/index.html#standard-module-structure"
48-
- name: "Terraform Module Requirements"
49-
description: "HashiCorp's guidance on all the requirements for publishing a module. Meeting the requirements for publishing a module is extremely easy."
50-
url: "https://www.terraform.io/docs/registry/modules/publish.html#requirements"
51-
- name: "Terraform `random_integer` Resource"
52-
description: "The resource random_integer generates random values from a given range, described by the min and max attributes of a given resource."
53-
url: "https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer"
54-
- name: "Terraform Version Pinning"
55-
description: "The required_version setting can be used to constrain which versions of the Terraform CLI can be used with your configuration"
56-
url: "https://www.terraform.io/docs/configuration/terraform.html#specifying-a-required-terraform-version"
57-
58-
# Short description of this project
60+
- name: terraform-provider-aws
61+
description: Terraform AWS provider
62+
url: https://registry.terraform.io/providers/hashicorp/aws/latest
63+
- name: terraform-provider-local
64+
description: Terraform local provider – Used to manage local resources, such as
65+
creating files.
66+
url: https://registry.terraform.io/providers/hashicorp/local/latest
5967
description: |-
60-
This is `terraform-example-module` project provides all the scaffolding for a typical well-built Cloud Posse module. It's a template repository you can
61-
use when creating new repositories.
68+
Terraform module to provision AWS Code Deploy app and group.
6269
6370
# Introduction to the project
6471
#introduction: |-
@@ -67,32 +74,32 @@ description: |-
6774
# How to use this module. Should be an easy example to copy and paste.
6875
usage: |-
6976
For a complete example, see [examples/complete](examples/complete).
70-
77+
7178
For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core) and [Terratest](https://github.com/gruntwork-io/terratest)
7279
(which tests and deploys the example on AWS), see [test](test).
7380
7481
```hcl
7582
module "example" {
76-
source = "https://github.com/cloudposse/terraform-example-module.git?ref=master"
83+
source = "https://github.com/cloudposse/terraform-aws-code-deploy.git?ref=master"
7784
example = "Hello world!"
7885
}
7986
```
8087
8188
# Example usage
8289
examples: |-
8390
Here is an example of using this module:
84-
- [`examples/complete`](https://github.com/cloudposse/terraform-example-module/) - complete example of using this module
91+
- [`examples/complete`](https://github.com/cloudposse/terraform-aws-code-deploy/) - complete example of using this module
8592
8693
# How to get started quickly
8794
#quickstart: |-
8895
# Here's how to get started...
8996

9097
# Other files to include in this README from the project folder
9198
include:
92-
- "docs/targets.md"
93-
- "docs/terraform.md"
99+
- docs/targets.md
100+
- docs/terraform.md
94101

95102
# Contributors to this project
96103
contributors:
97-
- name: "Erik Osterman"
98-
github: "osterman"
104+
- name: Vladimir Syromyatnikov
105+
github: SweetOps

docs/terraform.md

+41-7
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,76 @@
44
| Name | Version |
55
|------|---------|
66
| terraform | >= 0.13 |
7+
| aws | >= 2.0 |
78
| local | >= 1.2 |
8-
| random | >= 2.2 |
99

1010
## Providers
1111

1212
| Name | Version |
1313
|------|---------|
14-
| random | >= 2.2 |
14+
| aws | >= 2.0 |
15+
16+
## Modules
17+
18+
| Name | Source | Version |
19+
|------|--------|---------|
20+
| sns_topic | cloudposse/sns-topic/aws | 0.16.0 |
21+
| this | cloudposse/label/null | 0.24.1 |
22+
23+
## Resources
24+
25+
| Name |
26+
|------|
27+
| [aws_codedeploy_app](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_app) |
28+
| [aws_codedeploy_deployment_config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_config) |
29+
| [aws_codedeploy_deployment_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group) |
30+
| [aws_iam_policy_document](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) |
31+
| [aws_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) |
32+
| [aws_iam_role_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) |
1533

1634
## Inputs
1735

1836
| Name | Description | Type | Default | Required |
1937
|------|-------------|------|---------|:--------:|
2038
| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
39+
| alarm\_configuration | Configuration of deployment to stop when a CloudWatch alarm detects that a metric has fallen below or exceeded a defined threshold.<br> alarms:<br> A list of alarms configured for the deployment group.<br> ignore\_poll\_alarm\_failure:<br> Indicates whether a deployment should continue if information about the current state of alarms cannot be retrieved from CloudWatch. | <pre>object({<br> alarms = list(string)<br> ignore_poll_alarm_failure = bool<br> })</pre> | `null` | no |
2140
| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no |
41+
| auto\_rollback\_configuration\_events | The event type or types that trigger a rollback. Supported types are `DEPLOYMENT_FAILURE` and `DEPLOYMENT_STOP_ON_ALARM`. | `string` | `"DEPLOYMENT_FAILURE"` | no |
42+
| autoscaling\_groups | A list of Autoscaling Groups associated with the deployment group. | `list(string)` | `[]` | no |
43+
| blue\_green\_deployment\_config | Configuration block of the blue/green deployment options for a deployment group, <br>see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#blue_green_deployment_config | `any` | `null` | no |
44+
| compute\_platform | The compute platform can either be `ECS`, `Lambda`, or `Server` | `string` | `"ECS"` | no |
2245
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
46+
| create\_default\_service\_role | Whether to create default IAM role ARN that allows deployments. | `bool` | `true` | no |
47+
| create\_default\_sns\_topic | Whether to create default SNS topic through which notifications are sent. | `bool` | `true` | no |
2348
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
49+
| deployment\_style | Configuration of the type of deployment, either in-place or blue/green, <br>you want to run and whether to route deployment traffic behind a load balancer.<br><br>deployment\_option:<br> Indicates whether to route deployment traffic behind a load balancer. <br> Possible values: `WITH_TRAFFIC_CONTROL`, `WITHOUT_TRAFFIC_CONTROL`.<br>deployment\_type:<br> Indicates whether to run an in-place deployment or a blue/green deployment.<br> Possible values: `IN_PLACE`, `BLUE_GREEN`. | <pre>object({<br> deployment_option = string<br> deployment_type = string<br> })</pre> | `null` | no |
50+
| ec2\_tag\_filter | A list of sets of tag filters. If multiple tag groups are specified, <br>any instance that matches to at least one tag filter of every tag group is selected.<br><br>key:<br> The key of the tag filter.<br>type:<br> The type of the tag filter, either `KEY_ONLY`, `VALUE_ONLY`, or `KEY_AND_VALUE`.<br>value:<br> The value of the tag filter. | <pre>list(object({<br> key = string<br> type = string<br> value = string<br> }))</pre> | `null` | no |
51+
| ecs\_service | Configuration block(s) of the ECS services for a deployment group.<br><br>cluster\_name:<br> The name of the ECS cluster. <br>service\_name:<br> The name of the ECS service. | <pre>list(object({<br> cluster_name = string<br> service_name = string<br> }))</pre> | `null` | no |
2452
| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
2553
| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
26-
| example | Example variable | `string` | `"hello world"` | no |
2754
| id\_length\_limit | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
2855
| label\_key\_case | The letter case of label keys (`tag` names) (i.e. `name`, `namespace`, `environment`, `stage`, `attributes`) to use in `tags`.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
2956
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
3057
| label\_value\_case | The letter case of output label values (also used in `tags` and `id`).<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Default value: `lower`. | `string` | `null` | no |
58+
| load\_balancer\_info | Single configuration block of the load balancer to use in a blue/green deployment, <br>see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group#load_balancer_info | `map(any)` | `null` | no |
59+
| minimum\_healthy\_hosts | type:<br> The type can either be `FLEET_PERCENT` or `HOST_COUNT`.<br>value:<br> The value when the type is `FLEET_PERCENT` represents the minimum number of healthy instances <br> as a percentage of the total number of instances in the deployment.<br> When the type is `HOST_COUNT`, the value represents the minimum number of healthy instances as an absolute value. | <pre>object({<br> type = string<br> value = number<br> })</pre> | `null` | no |
3160
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
3261
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
3362
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
63+
| service\_role\_arn | The service IAM role ARN that allows deployments. | `string` | `null` | no |
64+
| sns\_topic\_arn | The ARN of the SNS topic through which notifications are sent. | `string` | `null` | no |
3465
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
3566
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
67+
| traffic\_routing\_config | type:<br> Type of traffic routing config. One of `TimeBasedCanary`, `TimeBasedLinear`, `AllAtOnce`.<br>interval:<br> The number of minutes between the first and second traffic shifts of a deployment.<br>percentage:<br> The percentage of traffic to shift in the first increment of a deployment. | <pre>object({<br> type = string<br> interval = number<br> percentage = number<br> })</pre> | `null` | no |
68+
| trigger\_events | The event type or types for which notifications are triggered. <br>Some values that are supported: <br> `DeploymentStart`, `DeploymentSuccess`, `DeploymentFailure`, `DeploymentStop`, <br> `DeploymentRollback`, `InstanceStart`, `InstanceSuccess`, `InstanceFailure`. <br>See the CodeDeploy documentation for all possible values.<br>http://docs.aws.amazon.com/codedeploy/latest/userguide/monitoring-sns-event-notifications-create-trigger.html | `list(string)` | <pre>[<br> "DeploymentFailure"<br>]</pre> | no |
3669

3770
## Outputs
3871

3972
| Name | Description |
4073
|------|-------------|
41-
| example | Example output |
42-
| id | ID of the created example |
43-
| random | Stable random number for this example |
44-
74+
| deployment\_config\_id | The deployment config ID. |
75+
| deployment\_config\_name | The deployment group's config name. |
76+
| group\_id | The application group ID. |
77+
| id | The application ID. |
78+
| name | The application's name. |
4579
<!-- markdownlint-restore -->
+112-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,119 @@
11
region = "us-east-2"
22

3-
namespace = "eg"
3+
availability_zones = ["us-east-2a", "us-east-2b"]
44

5-
environment = "ue2"
5+
namespace = "cdp"
66

77
stage = "test"
88

9-
name = "example"
9+
name = "ecs-alb"
1010

11+
vpc_cidr_block = "172.16.0.0/16"
12+
13+
ecs_launch_type = "FARGATE"
14+
15+
network_mode = "awsvpc"
16+
17+
ignore_changes_task_definition = true
18+
19+
assign_public_ip = false
20+
21+
propagate_tags = "TASK_DEFINITION"
22+
23+
deployment_minimum_healthy_percent = 100
24+
25+
deployment_maximum_percent = 200
26+
27+
deployment_controller_type = "CODE_DEPLOY"
28+
29+
desired_count = 1
30+
31+
task_memory = 512
32+
33+
task_cpu = 256
34+
35+
container_name = "nginx"
36+
37+
container_image = "nginx:latest"
38+
39+
container_memory = 256
40+
41+
container_memory_reservation = 128
42+
43+
container_cpu = 256
44+
45+
container_essential = true
46+
47+
container_readonly_root_filesystem = false
48+
49+
container_environment = [
50+
{
51+
name = "string_var"
52+
value = "I am a string"
53+
},
54+
{
55+
name = "true_boolean_var"
56+
value = true
57+
},
58+
{
59+
name = "false_boolean_var"
60+
value = false
61+
},
62+
{
63+
name = "integer_var"
64+
value = 42
65+
}
66+
]
67+
68+
container_port_mappings = [
69+
{
70+
containerPort = 80
71+
hostPort = 80
72+
protocol = "tcp"
73+
},
74+
{
75+
containerPort = 443
76+
hostPort = 443
77+
protocol = "tcp"
78+
}
79+
]
80+
81+
internal = false
82+
83+
http_enabled = true
84+
85+
access_logs_enabled = false
86+
87+
alb_access_logs_s3_bucket_force_destroy = true
88+
89+
cross_zone_load_balancing_enabled = true
90+
91+
http2_enabled = true
92+
93+
idle_timeout = 60
94+
95+
ip_address_type = "ipv4"
96+
97+
deletion_protection_enabled = false
98+
99+
deregistration_delay = 15
100+
101+
health_check_path = "/"
102+
103+
health_check_port = "traffic-port"
104+
105+
health_check_timeout = 10
106+
107+
health_check_healthy_threshold = 2
108+
109+
health_check_unhealthy_threshold = 2
110+
111+
health_check_interval = 15
112+
113+
health_check_matcher = "200-399"
114+
115+
target_group_port = 80
116+
117+
target_group_target_type = "ip"
118+
119+
target_group_protocol = "HTTP"

0 commit comments

Comments
 (0)