$ terraform -v
Terraform v0.11.8
+ provider.aws v1.35.0
+ provider.template v1.0.0
# Route 53 Module
resource "aws_route53_record" "record1" {
zone_id = "${aws_route53_zone.base.zone_id}"
name = "<redacted>"
type = "CNAME"
ttl = "300"
records = ["<redacted>"]
}
resource "aws_route53_record" "record2" {
zone_id = "${aws_route53_zone.base.zone_id}"
name = "<redacted>"
type = "CNAME"
ttl = "300"
records = ["<redacted>"]
}
output "cnames" {
value = ["some.thing.com,${aws_route53_record.record1.name},${aws_route53_record.record2.name}"]
}
# CloudFront distribution
variable "cnames" {
type = "list"
}
resource "aws_cloudfront_distribution" "reappr-dev" {
.........
aliases = ["${var.cnames}"]
}
The debug output is massive and contains sensitive info. Can be privately shared upon request.
N/A
Terraform should have extracted the list from the variable and set the CNAMEs appropriately
The AWS API returned a 404:
Error: Error applying plan:
1 error(s) occurred:
* module.cf.aws_cloudfront_distribution.reappr-dev: 1 error(s) occurred:
* aws_cloudfront_distribution.reappr-dev: error updating CloudFront Distribution (ES9QE524IXBN): InvalidArgument: The parameter CNAME contains one or more parameters that are not valid.
status code: 400, request id: f553e53c-d70e-11e8-a6d2-ff00a0e2fdc0
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
2018-10-23T17:59:48.581-0400 [DEBUG] plugin.terraform-provider-aws_v1.35.0_x4: 2018/10/23 17:59:48 [ERR] plugin: plugin server: accept unix /var/folders/6d/y54y04v51t76038v3k2nflm40000gn/T/plugin661750983: use of closed network connection
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
Create the above resources, then apply.
Manually hard-coding CNAME record into distribution resource works.
One of the CNAMEs in the Route 53 module output is hard-coded due to a cycle error.
EDIT: Please ignore, turns out one of the domains I was providing as alias included an underscore character (xx_xx.my-domain.com) and it's not valid to use as CNAME. "Domain names must contain one or more dots (.) and can only include lower case alphanumeric characters, dashes (-), and, optionally, a leading "." to indicate all subdomains of the specified domain, for example, ".example.com".
--
I'm having the same issue with TF v0.12.13 and AWS provider v2.35.0. I wrote a module that creates the CF Distribution like this:
variable "aliases" {
type = list(string)
description = "List of aliases domains for the Cloudfront distribution"
}
resource "aws_cloudfront_distribution" "www-site-cloudfront" {
...
aliases = var.aliases
...
}
And I'm getting this error:
Error: error updating CloudFront Distribution (EXXXXXXXXX): InvalidArgument: The parameter CNAME contains one or more parameters that are not valid.
status code: 400, request id: 1a7bdb33-xxxxxxxxx
I got exactly the same error and luckily after reading @esanchezm post, I should change the CName into lower capital letter. Then the deployment complete successfully. Thanks a lot !