From fd2af7e3d5eac5ac9e7768c99c9c53186399ebf1 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Fri, 11 Jan 2019 03:03:52 -0800 Subject: [PATCH] Pass attributes (#19) * Pass attributes * add output * Remove deprecated var * Add attributes * update readme * increase label version * Increase label ver * Bump aws-ecs-alb-service to 0.6.3 --- README.md | 109 ++++++++++++++++++++++++++++++++++++---------- docs/terraform.md | 5 ++- main.tf | 16 ++++--- outputs.tf | 5 +++ 4 files changed, 104 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index aee28d15..3f938ac1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ +[![README Header][readme_header_img]][readme_header_link] -[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com) +[![Cloud Posse][logo]](https://cpco.io/homepage) # terraform-aws-ecs-web-app [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-ecs-web-app.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-ecs-web-app) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-ecs-web-app.svg)](https://github.com/cloudposse/terraform-aws-ecs-web-app/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) @@ -10,7 +11,17 @@ A Terraform module which implements a web app on ECS and supporting AWS resource --- -This project is part of our comprehensive ["SweetOps"](https://docs.cloudposse.com) approach towards DevOps. +This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps. +[][share_email] +[][share_googleplus] +[][share_facebook] +[][share_reddit] +[][share_linkedin] +[][share_twitter] + + +[![Terraform Open Source Modules](https://docs.cloudposse.com/images/terraform-open-source-modules.svg)][terraform_modules] + It's 100% Open Source and licensed under the [APACHE2](LICENSE). @@ -21,6 +32,11 @@ It's 100% Open Source and licensed under the [APACHE2](LICENSE). +We literally have [*hundreds of terraform modules*][terraform_modules] that are Open Source and well-maintained. Check them out! + + + + @@ -71,7 +87,6 @@ Available targets: lint Lint terraform code ``` - ## Inputs | Name | Description | Type | Default | Required | @@ -92,6 +107,7 @@ Available targets: | alb_target_group_alarms_ok_actions | A list of ARNs (i.e. SNS Topic ARN) to execute when ALB Target Group alarms transition into an OK state from any other state. | list | `` | no | | alb_target_group_alarms_period | The period (in seconds) to analyze for ALB CloudWatch Alarms. | string | `300` | no | | alb_target_group_alarms_response_time_threshold | The maximum ALB Target Group response time. | string | `0.5` | no | +| alb_target_group_arn | Pass target group down to module | string | `` | no | | attributes | List of attributes to add to label. | list | `` | no | | autoscaling_dimension | Dimension to autoscale on (valid options: cpu, memory) | string | `memory` | no | | autoscaling_enabled | A boolean to enable/disable Autoscaling policy for ECS Service. | string | `false` | no | @@ -145,6 +161,7 @@ Available targets: | listener_arns_count | Number of elements in list of ALB Listener ARNs for the ECS service. | string | - | yes | | name | Name (unique identifier for app or service) | string | - | yes | | namespace | Namespace (e.g. `cp` or `cloudposse`) | string | - | yes | +| port_mappings | The port mappings to configure for the container. This is a list of maps. Each map should contain "containerPort", "hostPort", and "protocol", where "protocol" is one of "tcp" or "udp". If using containers in a task with the awsvpc or host network mode, the hostPort can either be left blank or set to the same value as the containerPort. | list | `` | no | | protocol | The protocol used for the port mapping. Options: tcp or udp. | string | `tcp` | no | | repo_name | GitHub repository name of the application to be built and deployed to ECS. | string | `` | no | | repo_owner | GitHub Organization or Username. | string | `` | no | @@ -159,9 +176,18 @@ Available targets: | scale_down_policy_arn | Autoscaling scale up policy ARN | | scale_up_policy_arn | Autoscaling scale up policy ARN | | service_name | ECS Service Name | +| service_security_group_id | Security Group id of the ECS task | | task_role_arn | ECS Task role ARN | +| task_role_name | ECS Task role name | + + +## Share the Love + +Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/terraform-aws-ecs-web-app)! (it helps us **a lot**) + +Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =) ## Related Projects @@ -185,26 +211,38 @@ Check out these related projects. File a GitHub [issue](https://github.com/cloudposse/terraform-aws-ecs-web-app/issues), send us an [email][email] or join our [Slack Community][slack]. +[![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link] + ## Commercial Support Work directly with our team of DevOps experts via email, slack, and video conferencing. We provide [*commercial support*][commercial_support] for all of our [Open Source][github] projects. As a *Dedicated Support* customer, you have access to our team of subject matter experts at a fraction of the cost of a full-time engineer. -[![E-Mail](https://img.shields.io/badge/email-hello@cloudposse.com-blue.svg)](mailto:hello@cloudposse.com) +[![E-Mail](https://img.shields.io/badge/email-hello@cloudposse.com-blue.svg)][email] - **Questions.** We'll use a Shared Slack channel between your team and ours. - **Troubleshooting.** We'll help you triage why things aren't working. - **Code Reviews.** We'll review your Pull Requests and provide constructive feedback. - **Bug Fixes.** We'll rapidly work to fix any bugs in our projects. -- **Build New Terraform Modules.** We'll develop original modules to provision infrastructure. +- **Build New Terraform Modules.** We'll [develop original modules][module_development] to provision infrastructure. - **Cloud Architecture.** We'll assist with your cloud strategy and design. - **Implementation.** We'll provide hands-on support to implement our reference architectures. -## Community Forum -Get access to our [Open Source Community Forum][slack] on Slack. It's **FREE** to join for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build *sweet* infrastructure. +## Terraform Module Development + +Are you interested in custom Terraform module development? Submit your inquiry using [our form][module_development] today and we'll get back to you ASAP. + + +## Slack Community + +Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. + +## Newsletter + +Signup for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover. ## Contributing @@ -214,7 +252,7 @@ Please use the [issue tracker](https://github.com/cloudposse/terraform-aws-ecs-w ### Developing -If you are interested in being a contributor and want to get involved in developing this project or [help out](https://github.com/orgs/cloudposse/projects/3) with our other projects, we would love to hear from you! Shoot us an [email](mailto:hello@cloudposse.com). +If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you! Shoot us an [email][email]. In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. @@ -229,7 +267,7 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. ## Copyright -Copyright © 2017-2018 [Cloud Posse, LLC](https://cloudposse.com) +Copyright © 2017-2019 [Cloud Posse, LLC](https://cpco.io/copyright) @@ -270,26 +308,16 @@ All other trademarks referenced herein are the property of their respective owne ## About -This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know at +This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know by [leaving a testimonial][testimonial]! -[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com) +[![Cloud Posse][logo]][website] -We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We love [Open Source Software](https://github.com/cloudposse/)! +We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We ❤️ [Open Source Software][we_love_open_source]. -We offer paid support on all of our projects. +We offer [paid support][commercial_support] on all of our projects. -Check out [our other projects][github], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation. +Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation. - [docs]: https://docs.cloudposse.com/ - [website]: https://cloudposse.com/ - [github]: https://github.com/cloudposse/ - [commercial_support]: https://github.com/orgs/cloudposse/projects - [jobs]: https://cloudposse.com/jobs/ - [hire]: https://cloudposse.com/contact/ - [slack]: https://slack.cloudposse.com/ - [linkedin]: https://www.linkedin.com/company/cloudposse - [twitter]: https://twitter.com/cloudposse/ - [email]: mailto:hello@cloudposse.com ### Contributors @@ -307,3 +335,36 @@ Check out [our other projects][github], [apply for a job][jobs], or [hire us][hi [sarkis_avatar]: https://github.com/sarkis.png?size=150 + +[![README Footer][readme_footer_img]][readme_footer_link] +[![Beacon][beacon]][website] + + [logo]: https://cloudposse.com/logo-300x69.svg + [docs]: https://cpco.io/docs + [website]: https://cpco.io/homepage + [github]: https://cpco.io/github + [jobs]: https://cpco.io/jobs + [hire]: https://cpco.io/hire + [slack]: https://cpco.io/slack + [linkedin]: https://cpco.io/linkedin + [twitter]: https://cpco.io/twitter + [testimonial]: https://cpco.io/leave-testimonial + [newsletter]: https://cpco.io/newsletter + [email]: https://cpco.io/email + [commercial_support]: https://cpco.io/commercial-support + [we_love_open_source]: https://cpco.io/we-love-open-source + [module_development]: https://cpco.io/module-development + [terraform_modules]: https://cpco.io/terraform-modules + [readme_header_img]: https://cloudposse.com/readme/header/img?repo=cloudposse/terraform-aws-ecs-web-app + [readme_header_link]: https://cloudposse.com/readme/header/link?repo=cloudposse/terraform-aws-ecs-web-app + [readme_footer_img]: https://cloudposse.com/readme/footer/img?repo=cloudposse/terraform-aws-ecs-web-app + [readme_footer_link]: https://cloudposse.com/readme/footer/link?repo=cloudposse/terraform-aws-ecs-web-app + [readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img?repo=cloudposse/terraform-aws-ecs-web-app + [readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?repo=cloudposse/terraform-aws-ecs-web-app + [share_twitter]: https://twitter.com/intent/tweet/?text=terraform-aws-ecs-web-app&url=https://github.com/cloudposse/terraform-aws-ecs-web-app + [share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=terraform-aws-ecs-web-app&url=https://github.com/cloudposse/terraform-aws-ecs-web-app + [share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/terraform-aws-ecs-web-app + [share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/terraform-aws-ecs-web-app + [share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/terraform-aws-ecs-web-app + [share_email]: mailto:?subject=terraform-aws-ecs-web-app&body=https://github.com/cloudposse/terraform-aws-ecs-web-app + [beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-ecs-web-app?pixel&cs=github&cm=readme&an=terraform-aws-ecs-web-app diff --git a/docs/terraform.md b/docs/terraform.md index eebb9143..3336f77b 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -1,4 +1,3 @@ - ## Inputs | Name | Description | Type | Default | Required | @@ -19,6 +18,7 @@ | alb_target_group_alarms_ok_actions | A list of ARNs (i.e. SNS Topic ARN) to execute when ALB Target Group alarms transition into an OK state from any other state. | list | `` | no | | alb_target_group_alarms_period | The period (in seconds) to analyze for ALB CloudWatch Alarms. | string | `300` | no | | alb_target_group_alarms_response_time_threshold | The maximum ALB Target Group response time. | string | `0.5` | no | +| alb_target_group_arn | Pass target group down to module | string | `` | no | | attributes | List of attributes to add to label. | list | `` | no | | autoscaling_dimension | Dimension to autoscale on (valid options: cpu, memory) | string | `memory` | no | | autoscaling_enabled | A boolean to enable/disable Autoscaling policy for ECS Service. | string | `false` | no | @@ -72,6 +72,7 @@ | listener_arns_count | Number of elements in list of ALB Listener ARNs for the ECS service. | string | - | yes | | name | Name (unique identifier for app or service) | string | - | yes | | namespace | Namespace (e.g. `cp` or `cloudposse`) | string | - | yes | +| port_mappings | The port mappings to configure for the container. This is a list of maps. Each map should contain "containerPort", "hostPort", and "protocol", where "protocol" is one of "tcp" or "udp". If using containers in a task with the awsvpc or host network mode, the hostPort can either be left blank or set to the same value as the containerPort. | list | `` | no | | protocol | The protocol used for the port mapping. Options: tcp or udp. | string | `tcp` | no | | repo_name | GitHub repository name of the application to be built and deployed to ECS. | string | `` | no | | repo_owner | GitHub Organization or Username. | string | `` | no | @@ -86,5 +87,7 @@ | scale_down_policy_arn | Autoscaling scale up policy ARN | | scale_up_policy_arn | Autoscaling scale up policy ARN | | service_name | ECS Service Name | +| service_security_group_id | Security Group id of the ECS task | | task_role_arn | ECS Task role ARN | +| task_role_name | ECS Task role name | diff --git a/main.tf b/main.tf index fbe02b33..b038edb0 100644 --- a/main.tf +++ b/main.tf @@ -1,8 +1,9 @@ module "default_label" { - source = "git::https://github.com/cloudposse/terraform-terraform-label.git?ref=tags/0.1.4" - name = "${var.name}" - namespace = "${var.namespace}" - stage = "${var.stage}" + source = "git::https://github.com/cloudposse/terraform-terraform-label.git?ref=tags/0.2.1" + name = "${var.name}" + namespace = "${var.namespace}" + stage = "${var.stage}" + attributes = "${var.attributes}" } module "ecr" { @@ -53,17 +54,17 @@ module "container_definition" { } module "ecs_alb_service_task" { - source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.6.0" + source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.6.3" name = "${var.name}" namespace = "${var.namespace}" stage = "${var.stage}" + attributes = "${var.attributes}" alb_target_group_arn = "${module.alb_ingress.target_group_arn}" container_definition_json = "${module.container_definition.json}" container_name = "${module.default_label.id}" desired_count = "${var.desired_count}" task_cpu = "${var.container_cpu}" task_memory = "${var.container_memory}" - ecr_repository_name = "${module.ecr.repository_name}" ecs_cluster_arn = "${var.ecs_cluster_arn}" launch_type = "${var.launch_type}" vpc_id = "${var.vpc_id}" @@ -78,6 +79,7 @@ module "ecs_codepipeline" { name = "${var.name}" namespace = "${var.namespace}" stage = "${var.stage}" + attributes = "${var.attributes}" github_oauth_token = "${var.github_oauth_token}" repo_owner = "${var.repo_owner}" repo_name = "${var.repo_name}" @@ -100,6 +102,7 @@ module "autoscaling" { name = "${var.name}" namespace = "${var.namespace}" stage = "${var.stage}" + attributes = "${var.attributes}" service_name = "${module.ecs_alb_service_task.service_name}" cluster_name = "${var.ecs_cluster_name}" min_capacity = "${var.autoscaling_min_capacity}" @@ -160,6 +163,7 @@ module "alb_target_group_alarms" { name = "${var.name}" namespace = "${var.namespace}" stage = "${var.stage}" + attributes = "${var.attributes}" alarm_actions = ["${var.alb_target_group_alarms_alarm_actions}"] ok_actions = ["${var.alb_target_group_alarms_ok_actions}"] insufficient_data_actions = ["${var.alb_target_group_alarms_insufficient_data_actions}"] diff --git a/outputs.tf b/outputs.tf index 74ed666a..86d9c793 100644 --- a/outputs.tf +++ b/outputs.tf @@ -13,6 +13,11 @@ output "service_name" { value = "${module.ecs_alb_service_task.service_name}" } +output "task_role_name" { + description = "ECS Task role name" + value = "${module.ecs_alb_service_task.task_role_name}" +} + output "task_role_arn" { description = "ECS Task role ARN" value = "${module.ecs_alb_service_task.task_role_arn}"