Skip to content

Commit

Permalink
BREAKING CHANGE: update internal modules to latest, replace `github_o…
Browse files Browse the repository at this point in the history
…rganization` with `github_owner`, bump Terraform version to >=0.13.1 (#218)
  • Loading branch information
bryantbiggs authored Aug 31, 2021
1 parent c20b132 commit c4de355
Show file tree
Hide file tree
Showing 30 changed files with 146 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
- name: Install pre-commit dependencies
run: |
pip install pre-commit
curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.13.0/terraform-docs-v0.13.0-$(uname)-amd64.tar.gz && tar -xzf terraform-docs.tar.gz && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.13.0/terraform-docs-v0.13.0-$(uname)-amd64.tar.gz && tar -xzf terraform-docs.tar.gz terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/
- name: Execute pre-commit
# Run all pre-commit checks on max version supported
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ $ cd terraform-aws-atlantis

5. Run `terraform output atlantis_url` to get URL where Atlantis is publicly reachable. (Note: It may take a minute or two to get it reachable for the first time)

6. Github webhook is automatically created if `github_token`, `github_organization` and `github_repo_names` were specified. Read [Add GitHub Webhook](https://github.com/runatlantis/atlantis#add-github-webhook) in the official Atlantis documentation or check [example "GitHub repository webhook for Atlantis"](https://github.com/terraform-aws-modules/terraform-aws-atlantis/tree/master/examples/github-repository-webhook) to add more webhooks.
6. Github webhook is automatically created if `github_token`, `github_owner` and `github_repo_names` were specified. Read [Add GitHub Webhook](https://github.com/runatlantis/atlantis#add-github-webhook) in the official Atlantis documentation or check [example "GitHub repository webhook for Atlantis"](https://github.com/terraform-aws-modules/terraform-aws-atlantis/tree/master/examples/github-repository-webhook) to add more webhooks.

### Run Atlantis as a Terraform module

Expand All @@ -55,7 +55,7 @@ This way allows integration with your existing Terraform configurations.
```hcl
module "atlantis" {
source = "terraform-aws-modules/atlantis/aws"
version = "~> 2.0"
version = "~> 3.0"
name = "atlantis"
Expand Down Expand Up @@ -209,7 +209,7 @@ allow_github_webhooks = true

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.26 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.68 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |

Expand All @@ -224,15 +224,15 @@ allow_github_webhooks = true

| Name | Source | Version |
|------|--------|---------|
| <a name="module_acm"></a> [acm](#module\_acm) | terraform-aws-modules/acm/aws | v2.12.0 |
| <a name="module_alb"></a> [alb](#module\_alb) | terraform-aws-modules/alb/aws | v5.10.0 |
| <a name="module_alb_http_sg"></a> [alb\_http\_sg](#module\_alb\_http\_sg) | terraform-aws-modules/security-group/aws//modules/http-80 | v3.17.0 |
| <a name="module_alb_https_sg"></a> [alb\_https\_sg](#module\_alb\_https\_sg) | terraform-aws-modules/security-group/aws//modules/https-443 | v3.17.0 |
| <a name="module_atlantis_sg"></a> [atlantis\_sg](#module\_atlantis\_sg) | terraform-aws-modules/security-group/aws | v3.17.0 |
| <a name="module_container_definition_bitbucket"></a> [container\_definition\_bitbucket](#module\_container\_definition\_bitbucket) | cloudposse/ecs-container-definition/aws | v0.45.2 |
| <a name="module_container_definition_github_gitlab"></a> [container\_definition\_github\_gitlab](#module\_container\_definition\_github\_gitlab) | cloudposse/ecs-container-definition/aws | v0.45.2 |
| <a name="module_ecs"></a> [ecs](#module\_ecs) | terraform-aws-modules/ecs/aws | v2.5.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | v2.64.0 |
| <a name="module_acm"></a> [acm](#module\_acm) | terraform-aws-modules/acm/aws | v3.2.0 |
| <a name="module_alb"></a> [alb](#module\_alb) | terraform-aws-modules/alb/aws | v6.5.0 |
| <a name="module_alb_http_sg"></a> [alb\_http\_sg](#module\_alb\_http\_sg) | terraform-aws-modules/security-group/aws//modules/http-80 | v4.3.0 |
| <a name="module_alb_https_sg"></a> [alb\_https\_sg](#module\_alb\_https\_sg) | terraform-aws-modules/security-group/aws//modules/https-443 | v4.3.0 |
| <a name="module_atlantis_sg"></a> [atlantis\_sg](#module\_atlantis\_sg) | terraform-aws-modules/security-group/aws | v4.3.0 |
| <a name="module_container_definition_bitbucket"></a> [container\_definition\_bitbucket](#module\_container\_definition\_bitbucket) | cloudposse/ecs-container-definition/aws | v0.58.1 |
| <a name="module_container_definition_github_gitlab"></a> [container\_definition\_github\_gitlab](#module\_container\_definition\_github\_gitlab) | cloudposse/ecs-container-definition/aws | v0.58.1 |
| <a name="module_ecs"></a> [ecs](#module\_ecs) | terraform-aws-modules/ecs/aws | v3.3.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | v3.6.0 |

## Resources

Expand All @@ -255,6 +255,7 @@ allow_github_webhooks = true
| [aws_iam_policy_document.ecs_task_access_secrets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.ecs_task_access_secrets_with_kms](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.ecs_tasks](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [aws_route53_zone.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route53_zone) | data source |

Expand Down Expand Up @@ -335,7 +336,7 @@ allow_github_webhooks = true
| <a name="input_mount_points"></a> [mount\_points](#input\_mount\_points) | Container mount points. This is a list of maps, where each map should contain a `containerPath` and `sourceVolume`. The `readOnly` key is optional. | `list(any)` | `[]` | no |
| <a name="input_name"></a> [name](#input\_name) | Name to use on all resources created (VPC, ALB, etc) | `string` | `"atlantis"` | no |
| <a name="input_permissions_boundary"></a> [permissions\_boundary](#input\_permissions\_boundary) | If provided, all IAM roles will be created with this permissions boundary attached. | `string` | `null` | no |
| <a name="input_policies_arn"></a> [policies\_arn](#input\_policies\_arn) | A list of the ARN of the policies you want to apply | `list(string)` | <pre>[<br> "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"<br>]</pre> | no |
| <a name="input_policies_arn"></a> [policies\_arn](#input\_policies\_arn) | A list of the ARN of the policies you want to apply | `list(string)` | `null` | no |
| <a name="input_private_subnet_ids"></a> [private\_subnet\_ids](#input\_private\_subnet\_ids) | A list of IDs of existing private subnets inside the VPC | `list(string)` | `[]` | no |
| <a name="input_private_subnets"></a> [private\_subnets](#input\_private\_subnets) | A list of private subnets inside the VPC | `list(string)` | `[]` | no |
| <a name="input_propagate_tags"></a> [propagate\_tags](#input\_propagate\_tags) | Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are SERVICE and TASK\_DEFINITION | `string` | `null` | no |
Expand Down
13 changes: 5 additions & 8 deletions examples/github-complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GitHub's personal access token can be generated at https://github.com/settings/t

## Usage

To run this code you need to copy `terraform.tfvars.sample` into `terraform.tfvars` and update the values locally or specify them using environment variables (`TF_VAR_github_token=xxx`, `TF_VAR_github_organization=xxx`, etc.). Once ready, execute:
To run this code you need to copy `terraform.tfvars.sample` into `terraform.tfvars` and update the values locally or specify them using environment variables (`TF_VAR_github_token=xxx`, `TF_VAR_github_owner=xxx`, etc.). Once ready, execute:

```bash
$ terraform init
Expand All @@ -29,9 +29,9 @@ Go to https://eu-west-1.console.aws.amazon.com/ecs/home?region=eu-west-1#/settin

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.26 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.68 |
| <a name="requirement_github"></a> [github](#requirement\_github) | >= 2.4.1 |
| <a name="requirement_github"></a> [github](#requirement\_github) | >= 4.8 |

## Providers

Expand All @@ -44,7 +44,7 @@ Go to https://eu-west-1.console.aws.amazon.com/ecs/home?region=eu-west-1#/settin
| Name | Source | Version |
|------|--------|---------|
| <a name="module_atlantis"></a> [atlantis](#module\_atlantis) | ../../ | |
| <a name="module_atlantis_access_log_bucket"></a> [atlantis\_access\_log\_bucket](#module\_atlantis\_access\_log\_bucket) | terraform-aws-modules/s3-bucket/aws | >= 1.9 |
| <a name="module_atlantis_access_log_bucket"></a> [atlantis\_access\_log\_bucket](#module\_atlantis\_access\_log\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 2 |
| <a name="module_github_repository_webhook"></a> [github\_repository\_webhook](#module\_github\_repository\_webhook) | ../../modules/github-repository-webhook | |

## Resources
Expand All @@ -63,12 +63,9 @@ Go to https://eu-west-1.console.aws.amazon.com/ecs/home?region=eu-west-1#/settin
| <a name="input_alb_ingress_cidr_blocks"></a> [alb\_ingress\_cidr\_blocks](#input\_alb\_ingress\_cidr\_blocks) | List of IPv4 CIDR ranges to use on all ingress rules of the ALB - use your personal IP in the form of `x.x.x.x/32` for restricted testing | `list(string)` | n/a | yes |
| <a name="input_allowed_repo_names"></a> [allowed\_repo\_names](#input\_allowed\_repo\_names) | Repositories that Atlantis will listen for events from and a webhook will be installed | `list(string)` | n/a | yes |
| <a name="input_domain"></a> [domain](#input\_domain) | Route53 domain name to use for ACM certificate. Route53 zone for this domain should be created in advance | `string` | n/a | yes |
| <a name="input_github_organization"></a> [github\_organization](#input\_github\_organization) | Github organization | `string` | n/a | yes |
| <a name="input_github_owner"></a> [github\_owner](#input\_github\_owner) | Github owner | `string` | n/a | yes |
| <a name="input_github_token"></a> [github\_token](#input\_github\_token) | Github token | `string` | n/a | yes |
| <a name="input_github_user"></a> [github\_user](#input\_github\_user) | Github user for Atlantis to utilize when performing Github activities | `string` | n/a | yes |
| <a name="input_region"></a> [region](#input\_region) | AWS region where resources will be created | `string` | `"us-east-1"` | no |
| <a name="input_trusted_entities"></a> [trusted\_entities](#input\_trusted\_entities) | A list of users or roles, that can assume the task role | `list(string)` | `[]` | no |
| <a name="input_trusted_principals"></a> [trusted\_principals](#input\_trusted\_principals) | A list of principals, in addition to ecs-tasks.amazonaws.com, that can assume the task role | `list(string)` | n/a | yes |

## Outputs

Expand Down
32 changes: 17 additions & 15 deletions examples/github-complete/main.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
provider "aws" {
region = var.region
region = local.region
}

locals {
name = "github-complete"
region = "eu-west-1"

tags = {
Owner = "user"
Environment = "dev"
}
}

##############################################################
# Data sources for existing resources
##############################################################
################################################################################
# Supporting Resources
################################################################################

data "aws_caller_identity" "current" {}

Expand All @@ -26,11 +29,11 @@ data "aws_elb_service_account" "current" {}
module "atlantis" {
source = "../../"

name = "atlantiscomplete"
name = local.name

# VPC
cidr = "10.20.0.0/16"
azs = ["${var.region}a", "${var.region}b", "${var.region}c"]
azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
private_subnets = ["10.20.1.0/24", "10.20.2.0/24", "10.20.3.0/24"]
public_subnets = ["10.20.101.0/24", "10.20.102.0/24", "10.20.103.0/24"]

Expand Down Expand Up @@ -62,17 +65,16 @@ module "atlantis" {
hardLimit = 16384
}]

# Security
trusted_principals = var.trusted_principals
trusted_entities = var.trusted_entities

# DNS
route53_zone_name = var.domain

# Trusted roles
trusted_principals = ["ssm.amazonaws.com"]

# Atlantis
atlantis_github_user = var.github_user
atlantis_github_user_token = var.github_token
atlantis_repo_allowlist = ["github.com/${var.github_organization}/*"]
atlantis_repo_allowlist = ["github.com/${var.github_owner}/*"]
atlantis_allowed_repo_names = var.allowed_repo_names

# ALB access
Expand All @@ -97,8 +99,8 @@ module "atlantis" {
module "github_repository_webhook" {
source = "../../modules/github-repository-webhook"

github_organization = var.github_organization
github_token = var.github_token
github_owner = var.github_owner
github_token = var.github_token

atlantis_allowed_repo_names = module.atlantis.atlantis_allowed_repo_names

Expand All @@ -111,9 +113,9 @@ module "github_repository_webhook" {
################################################################################
module "atlantis_access_log_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
version = ">= 1.9"
version = "~> 2"

bucket = "${data.aws_caller_identity.current.account_id}-atlantis-access-logs-${data.aws_region.current.name}"
bucket = "atlantis-access-logs-${data.aws_caller_identity.current.account_id}-${data.aws_region.current.name}"

attach_policy = true
policy = data.aws_iam_policy_document.atlantis_access_log_bucket_policy.json
Expand Down
4 changes: 2 additions & 2 deletions examples/github-complete/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ output "ecs_task_definition" {
# Webhooks
output "github_webhook_urls" {
description = "Github webhook URL"
value = module.github_repository_webhook.this_repository_webhook_urls
value = module.github_repository_webhook.repository_webhook_urls
}

output "github_webhook_secret" {
description = "Github webhook secret"
value = module.github_repository_webhook.this_repository_webhook_secret
value = module.github_repository_webhook.repository_webhook_secret
}
4 changes: 1 addition & 3 deletions examples/github-complete/terraform.tfvars.sample
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
region = "eu-west-1"
domain = "mydomain.com"
alb_ingress_cidr_blocks = ["x.x.x.x/32"]
github_organization = "myorg"
github_owner = "myorg"
github_user = "atlantis"
github_token = "mygithubpersonalaccesstokenforatlantis"
allowed_repo_names = ["repo1", "repo2"]
trusted_principals = ["ssm.amazonaws.com"] # Convenient if you want to enable SSM access into Atlantis for troubleshooting etc
21 changes: 2 additions & 19 deletions examples/github-complete/variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
variable "region" {
description = "AWS region where resources will be created"
type = string
default = "us-east-1"
}

variable "domain" {
description = "Route53 domain name to use for ACM certificate. Route53 zone for this domain should be created in advance"
type = string
Expand All @@ -19,8 +13,8 @@ variable "github_token" {
type = string
}

variable "github_organization" {
description = "Github organization"
variable "github_owner" {
description = "Github owner"
type = string
}

Expand All @@ -33,14 +27,3 @@ variable "allowed_repo_names" {
description = "Repositories that Atlantis will listen for events from and a webhook will be installed"
type = list(string)
}

variable "trusted_principals" {
description = "A list of principals, in addition to ecs-tasks.amazonaws.com, that can assume the task role"
type = list(string)
}

variable "trusted_entities" {
description = "A list of users or roles, that can assume the task role"
type = list(string)
default = []
}
4 changes: 2 additions & 2 deletions examples/github-complete/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.12.26"
required_version = ">= 0.13.1"

required_providers {
aws = {
Expand All @@ -9,7 +9,7 @@ terraform {

github = {
source = "integrations/github"
version = ">= 2.4.1"
version = ">= 4.8"
}
}
}
12 changes: 6 additions & 6 deletions examples/github-repository-webhook/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# GitHub repository webhook for Atlantis

Configuration in this directory creates GitHub repository webhooks configured to Atlantis URL. This example uses value of webhook secret which got generated when Atlantis setup by referring to `terraform.tfstate`, so this example has to run after Atlantis.
Configuration in this directory creates GitHub repository webhooks configured to Atlantis URL. This example uses value of webhook secret which got generated when Atlantis setup by referring to `terraform.tfstate`, so this example has to run after Atlantis.

GitHub's personal access token can be generated at https://github.com/settings/tokens
GitHub's personal access token can be generated at https://github.com/settings/tokens

## Usage

To run this code you need to copy `terraform.tfvars.sample` into `terraform.tfvars` and put your GitHub token and Github organization there or specify them using environment variables (`TF_VAR_github_token` and `TF_VAR_github_organization`). Once ready, execute:
To run this code you need to copy `terraform.tfvars.sample` into `terraform.tfvars` and put your GitHub token and Github owner there or specify them using environment variables (`TF_VAR_github_token` and `TF_VAR_github_owner`). Once ready, execute:

```bash
$ terraform init
Expand All @@ -21,9 +21,9 @@ Note that this example may create resources which cost money. Run `terraform des

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.26 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.68 |
| <a name="requirement_github"></a> [github](#requirement\_github) | >= 2.4.1 |
| <a name="requirement_github"></a> [github](#requirement\_github) | >= 4.8 |

## Providers

Expand All @@ -47,7 +47,7 @@ Note that this example may create resources which cost money. Run `terraform des

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_github_organization"></a> [github\_organization](#input\_github\_organization) | Github organization | `string` | n/a | yes |
| <a name="input_github_owner"></a> [github\_owner](#input\_github\_owner) | Github owner | `string` | n/a | yes |
| <a name="input_github_token"></a> [github\_token](#input\_github\_token) | Github token | `string` | n/a | yes |

## Outputs
Expand Down
Loading

0 comments on commit c4de355

Please sign in to comment.