Skip to content

Commit

Permalink
🩹 fix account-alias usage (#17)
Browse files Browse the repository at this point in the history
* 🩹 fix account-alias usage

* terraform-docs: automated update action

* 🩹 fix account-alias usage

* terraform-docs: automated update action

* ⬆️ updagra terraform version constraint

* terraform-docs: automated update action

* 🩹 fix account-alias usage

* terraform-docs: automated update action

* 🩹 fix account-alias usage

* terraform-docs: automated update action

Co-authored-by: wvxavier <[email protected]>
  • Loading branch information
wvxavier and wvxavier authored Feb 14, 2022
1 parent c4fc87f commit 451633e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
name: Minimum version check
runs-on: ubuntu-latest
container:
image: hashicorp/terraform:0.12.0
image: hashicorp/terraform:0.12.20
steps:
- uses: actions/checkout@master
- name: Validate Code
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ If you have specified cloudfront_default_certificate, TLSv1 must be specified.

| Name | Version |
|------|---------|
| terraform | >= 0.12.0 |
| terraform | >= 0.12.20 |

## Providers

Expand All @@ -52,6 +52,7 @@ If you have specified cloudfront_default_certificate, TLSv1 must be specified.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| alarm\_cloudfront\_500\_errors\_threshold | Cloudfront 500 Errors rate threshold (use 0 to disable this alarm) | `number` | `5` | no |
| alarm\_prefix | String prefix for cloudwatch alarms. (Optional) | `string` | `"alarm"` | no |
| alarm\_sns\_topics\_us | Alarm topics to create and alert on metrics on US region | `list` | `[]` | no |
| alb\_cloudfront\_key | Key generated by terraform-aws-ecs module to allow ALB connection from CloudFront | `any` | n/a | yes |
| alb\_dns\_name | ALB DNS Name that CloudFront will point as origin | `any` | n/a | yes |
Expand Down
4 changes: 3 additions & 1 deletion _data.tf
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
data "aws_iam_account_alias" "current" {}
data "aws_iam_account_alias" "current" {
count = var.alarm_prefix == "" ? 1 : 0
}
6 changes: 6 additions & 0 deletions _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ variable "dynamic_ordered_cache_behavior" {
type = any
default = []
}

variable "alarm_prefix" {
type = string
description = "String prefix for cloudwatch alarms. (Optional)"
default = "alarm"
}
2 changes: 1 addition & 1 deletion cloudwatch-alarms.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "aws_cloudwatch_metric_alarm" "cloudfront_500_errors" {
provider = aws.us-east-1
count = length(var.alarm_sns_topics_us) > 0 && var.alarm_cloudfront_500_errors_threshold != 0 ? 1 : 0

alarm_name = "${data.aws_iam_account_alias.current.account_alias}-ecs-${var.cluster_name}-${var.name}-cloudfront-500-errors"
alarm_name = try(data.aws_iam_account_alias.current[0].account_alias, "${var.alarm_prefix}-ecs-${var.name}-cloudfront-500-errors")
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "3"
metric_name = "5xxErrorRate"
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
terraform {
required_version = ">= 0.12.0"
required_version = ">= 0.12.20"
}

0 comments on commit 451633e

Please sign in to comment.