terraform-aws-cloudfront-s3-cdn icon indicating copy to clipboard operation
terraform-aws-cloudfront-s3-cdn copied to clipboard

Requires a "region" that is not documented

Open marcottedan opened this issue 3 years ago • 2 comments

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

Hi! When I use your module:

module "cdn" {
  source = "cloudposse/cloudfront-s3-cdn/aws"
  version = "0.75.0"

  namespace         = "ir"
  stage             = "dev"
  name              = "cdn"
  aliases           = ["cdn.example.com"]
  dns_alias_enabled = true
  parent_zone_name  = "example.com"

  deployment_principal_arns = {
    "arn:aws:iam::123456789012:role/principal1" = ["prefix1/", "prefix2/"]
    "arn:aws:iam::123456789012:role/principal2" = [""]
  }
}

I get the following error which I'm not sure how to fix:

terraform plan
╷
│ Error: Missing required argument
│ 
│ The argument "region" is required, but was not set.

I tried to set a AWS provider:

provider "aws" {
  region = "us-east-1"
  profile = "my-aws-account-profile-dev"
}

But then I get the following error:

╷
│ Error: no matching Route53Zone found
│ 
│   with module.cdn.module.dns.data.aws_route53_zone.default[0],
│   on .terraform/modules/cdn.dns/main.tf line 1, in data "aws_route53_zone" "default":
│    1: data "aws_route53_zone" "default" {
│ 
╵

Expected Behavior

I think I should have an AWS generated cloudfront with their domain name no?

Steps to Reproduce

Steps to reproduce the behavior:

  1. Use your template in a main.tf
  2. terraform plan

Screenshots

N/A

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • MacOS terraform -version Terraform v1.0.5 on darwin_amd64
  • provider registry.terraform.io/hashicorp/aws v3.57.0
  • provider registry.terraform.io/hashicorp/local v2.1.0
  • provider registry.terraform.io/hashicorp/random v3.1.0

Additional Context

N/A

marcottedan avatar Sep 07 '21 20:09 marcottedan

OK I had to do the following change so the base example works:

module "cdn" {
  source = "cloudposse/cloudfront-s3-cdn/aws"
  version = "0.75.0"

  namespace         = "ir"
  stage             = "dev"
  name              = "cdn"
//  aliases           = ["cdn.example.com"]
  dns_alias_enabled = false
//  parent_zone_name  = "example.com"

  deployment_principal_arns = {
    "arn:aws:iam::123456789012:role/principal1" = ["prefix1/", "prefix2/"]
    "arn:aws:iam::123456789012:role/principal2" = [""]
  }
}

But then I got the following error:

╷
│ Error: Error putting S3 policy: MalformedPolicy: Invalid principal in policy
│       status code: 400, request id: 3JRRR9XPXSJ5VYBQ, host id: wTwGdC0Gro7MxFwe6BvnQ7Vq3AsltjUsM2HnBGs9QoOLKGz14tzyRm5Px76yyyqqs1CusKRgaOo=
│ 
│   with module.cdn.aws_s3_bucket_policy.default[0],
│   on .terraform/modules/cdn/main.tf line 221, in resource "aws_s3_bucket_policy" "default":
│  221: resource "aws_s3_bucket_policy" "default" {
│ 
╵

I'm not sure how/where to configure those principals so I'll investigate that.

marcottedan avatar Sep 07 '21 20:09 marcottedan

I'm having the same problem

olivatooo avatar Oct 20 '21 23:10 olivatooo