diff --git a/CHANGELOG.md b/CHANGELOG.md index 484baf9..d091dca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ All notable changes to this project will be documented in this file. +## [3.0.0](https://github.com/terraform-aws-modules/terraform-aws-appsync/compare/v2.6.0...v3.0.0) (2025-01-09) + + +### ⚠ BREAKING CHANGES + +* Rename resource aws_appsync_api_cache (#70) + +### Miscellaneous Chores + +* Rename resource aws_appsync_api_cache ([#70](https://github.com/terraform-aws-modules/terraform-aws-appsync/issues/70)) ([4b7f0b1](https://github.com/terraform-aws-modules/terraform-aws-appsync/commit/4b7f0b1e5d940d4059e29ca7fc408978bfe85842)) + ## [2.6.0](https://github.com/terraform-aws-modules/terraform-aws-appsync/compare/v2.5.1...v2.6.0) (2025-01-07) diff --git a/README.md b/README.md index 7a8ca6f..f1deb47 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ $ terraform apply | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 1.0 | +| [terraform](#requirement\_terraform) | >= 1.3.2 | | [aws](#requirement\_aws) | >= 5.61.0 | ## Providers @@ -149,7 +149,7 @@ No modules. | Name | Type | |------|------| -| [aws_appsync_api_cache.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appsync_api_cache) | resource | +| [aws_appsync_api_cache.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appsync_api_cache) | resource | | [aws_appsync_api_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appsync_api_key) | resource | | [aws_appsync_datasource.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appsync_datasource) | resource | | [aws_appsync_domain_name.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appsync_domain_name) | resource | diff --git a/examples/complete/README.md b/examples/complete/README.md index 5ad70fa..dbfbdfc 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -29,13 +29,14 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 5.1 | +| [aws.us-east-1](#provider\_aws.us-east-1) | >= 5.1 | | [random](#provider\_random) | >= 2.0 | ## Modules | Name | Source | Version | |------|--------|---------| -| [acm](#module\_acm) | terraform-aws-modules/acm/aws | ~> 3 | +| [acm](#module\_acm) | terraform-aws-modules/acm/aws | ~> 5.0 | | [appsync](#module\_appsync) | ../../ | n/a | | [disabled](#module\_disabled) | ../../ | n/a | @@ -48,11 +49,20 @@ Note that this example may create resources which cost money. Run `terraform des | [aws_route53_record.api](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | | [aws_route53_zone.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource | | [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource | +| [aws_acm_certificate.existing_certificate](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/acm_certificate) | data source | +| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | 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 | ## Inputs -No inputs. +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [existing\_acm\_certificate\_domain\_name](#input\_existing\_acm\_certificate\_domain\_name) | Existing ACM certificate domain name | `string` | `"terraform-aws-modules.modules.tf"` | no | +| [region](#input\_region) | AWS region where resources will be created | `string` | `"eu-west-1"` | no | +| [route53\_domain\_name](#input\_route53\_domain\_name) | Existing Route 53 domain name | `string` | `"terraform-aws-modules.modules.tf"` | no | +| [use\_existing\_acm\_certificate](#input\_use\_existing\_acm\_certificate) | Whether to use an existing ACM certificate | `bool` | `false` | no | +| [use\_existing\_route53\_zone](#input\_use\_existing\_route53\_zone) | Whether to use an existing Route 53 zone | `bool` | `true` | no | ## Outputs diff --git a/examples/complete/main.tf b/examples/complete/main.tf index d6d6eb7..28226fd 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -1,5 +1,5 @@ provider "aws" { - region = "eu-west-1" + region = var.region # Make it faster by skipping something skip_metadata_api_check = true @@ -24,53 +24,61 @@ provider "aws" { } locals { - # Use existing (via data source) or create new zone (will fail validation, if zone is not reachable) - use_existing_route53_zone = true - - domain = "terraform-aws-modules.modules.tf" - # Removing trailing dot from domain - just to be sure :) - domain_name = trimsuffix(local.domain, ".") + route53_domain_name = trimsuffix(var.route53_domain_name, ".") } data "aws_route53_zone" "this" { - count = local.use_existing_route53_zone ? 1 : 0 + count = var.use_existing_route53_zone ? 1 : 0 - name = local.domain_name + name = local.route53_domain_name private_zone = false } resource "aws_route53_zone" "this" { - count = !local.use_existing_route53_zone ? 1 : 0 - name = local.domain_name + count = !var.use_existing_route53_zone ? 1 : 0 + + name = local.route53_domain_name } resource "aws_route53_record" "api" { zone_id = try(data.aws_route53_zone.this[0].zone_id, aws_route53_zone.this[0].zone_id) - name = "api.${local.domain}" + name = "api.${var.route53_domain_name}" type = "CNAME" ttl = "300" records = [module.appsync.appsync_domain_name] } +data "aws_acm_certificate" "existing_certificate" { + count = var.use_existing_acm_certificate ? 1 : 0 + + domain = var.existing_acm_certificate_domain_name + + provider = aws.us-east-1 +} + module "acm" { + count = var.use_existing_acm_certificate ? 0 : 1 + source = "terraform-aws-modules/acm/aws" - version = "~> 3" + version = "~> 5.0" - domain_name = local.domain_name + domain_name = local.route53_domain_name zone_id = try(data.aws_route53_zone.this[0].zone_id, aws_route53_zone.this[0].zone_id) subject_alternative_names = [ - "*.alerts.${local.domain_name}", - "new.sub.${local.domain_name}", - "*.${local.domain_name}", - "alerts.${local.domain_name}", + "*.alerts.${local.route53_domain_name}", + "new.sub.${local.route53_domain_name}", + "*.${local.route53_domain_name}", + "alerts.${local.route53_domain_name}", ] wait_for_validation = true + validation_method = "DNS" + tags = { - Name = local.domain_name + Name = local.route53_domain_name } providers = { @@ -78,6 +86,9 @@ module "acm" { } } +data "aws_caller_identity" "current" {} +data "aws_region" "current" {} + module "appsync" { source = "../../" @@ -94,9 +105,9 @@ module "appsync" { query_depth_limit = 10 resolver_count_limit = 25 - domain_name = "api.${local.domain}" + domain_name = "api.${var.route53_domain_name}" domain_name_description = "My ${random_pet.this.id} AppSync Domain" - certificate_arn = module.acm.acm_certificate_arn + certificate_arn = var.use_existing_acm_certificate ? data.aws_acm_certificate.existing_certificate[0].arn : module.acm[0].acm_certificate_arn caching_behavior = "PER_RESOLVER_CACHING" cache_type = "SMALL" @@ -147,7 +158,7 @@ module "appsync" { lambda = { authentication_type = "AWS_LAMBDA" lambda_authorizer_config = { - authorizer_uri = "arn:aws:lambda:eu-west-1:835367859851:function:appsync_auth_2" + authorizer_uri = "arn:aws:lambda:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:function:appsync_auth_2" } } } diff --git a/examples/complete/variables.tf b/examples/complete/variables.tf index e69de29..dc36335 100644 --- a/examples/complete/variables.tf +++ b/examples/complete/variables.tf @@ -0,0 +1,29 @@ +variable "region" { + description = "AWS region where resources will be created" + type = string + default = "eu-west-1" +} + +variable "use_existing_route53_zone" { + description = "Whether to use an existing Route 53 zone" + type = bool + default = true +} + +variable "route53_domain_name" { + description = "Existing Route 53 domain name" + type = string + default = "terraform-aws-modules.modules.tf" +} + +variable "use_existing_acm_certificate" { + description = "Whether to use an existing ACM certificate" + type = bool + default = false +} + +variable "existing_acm_certificate_domain_name" { + description = "Existing ACM certificate domain name" + type = string + default = "terraform-aws-modules.modules.tf" +} diff --git a/main.tf b/main.tf index 736e58a..7ae6847 100644 --- a/main.tf +++ b/main.tf @@ -129,7 +129,7 @@ resource "aws_appsync_domain_name_api_association" "this" { } # API Cache -resource "aws_appsync_api_cache" "example" { +resource "aws_appsync_api_cache" "this" { count = var.create_graphql_api && var.caching_enabled ? 1 : 0 api_id = aws_appsync_graphql_api.this[0].id diff --git a/migrations.tf b/migrations.tf new file mode 100644 index 0000000..dcab3d5 --- /dev/null +++ b/migrations.tf @@ -0,0 +1,8 @@ +################################################################################ +# Migrations: v2.6.0 -> v3.0.0 +################################################################################ + +moved { + from = aws_appsync_api_cache.example + to = aws_appsync_api_cache.this +} diff --git a/versions.tf b/versions.tf index ee879be..f6024da 100644 --- a/versions.tf +++ b/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 1.0" + required_version = ">= 1.3.2" required_providers { aws = { diff --git a/wrappers/versions.tf b/wrappers/versions.tf index ee879be..f6024da 100644 --- a/wrappers/versions.tf +++ b/wrappers/versions.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 1.0" + required_version = ">= 1.3.2" required_providers { aws = {