Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_ses_domain_identity.default is tuple with 1 element #16

Closed
ZeroDeth opened this issue Jun 30, 2022 · 1 comment · Fixed by #17
Closed

aws_ses_domain_identity.default is tuple with 1 element #16

ZeroDeth opened this issue Jun 30, 2022 · 1 comment · Fixed by #17

Comments

@ZeroDeth
Copy link

Hello,

Trying to enable mail from domain to use mail.example.com

Example

module "example_ses" {
  source  = "registry.terraform.io/clouddrove/ses/aws"
  version = "1.0.1"

  enable_domain = true
  domain        = "example.com"

  enable_mail_from = true
  mail_from_domain = "mail.example.com"

  enable_verification = true
  enable_mx           = true
  enable_spf_domain   = true

  cname_type = "CNAME"
  mx_type    = "MX"
  txt_type   = "TXT"
  zone_id    = data.aws_route53_zone.selected.id
}

## SES Policy
data "aws_iam_policy_document" "example_ses_policy" {
  statement {
    actions   = ["SES:SendEmail", "SES:SendRawEmail"]
    resources = [module.example_ses.domain_identity_arn]

    principals {
      type = "AWS"
      identifiers = [
        data.terraform_remote_state.dev_account.outputs.account_id,
        data.terraform_remote_state.stg_account.outputs.account_id
      ]
    }
  }
}

resource "aws_ses_identity_policy" "example_ses_identity_policy" {
  identity = module.example_ses.domain_identity_arn
  name     = "allow-account-id"
  policy   = data.aws_iam_policy_document.example_ses_policy.json
}

Error:

│ Error: Incorrect attribute value type
│ 
│   on .terraform/modules/example_ses/main.tf line 66, in resource "aws_ses_domain_mail_from" "default":
│   66:   domain           = aws_ses_domain_identity.default.*.domain
│     ├────────────────
│     │ aws_ses_domain_identity.default is tuple with 1 element
│ 
│ Inappropriate value for attribute "domain": string required.

I am sure not a bug and doing something wrong here.
Thanks

@agconti
Copy link
Contributor

agconti commented Jul 22, 2022

Yep, running to this same issue as well. Did you find a fix for it @ZeroDeth ?

agconti added a commit to agconti/terraform-aws-ses that referenced this issue Jul 22, 2022
Closes clouddrove#16 

Previously: 

```hcl
resource "aws_ses_identity_policy" "default" {
  count    = var.enable_policy ? 1 : 0
  identity = aws_ses_domain_identity.default.*.arn
  name     = var.policy_name
  policy   = data.aws_iam_policy_document.document.json
}
```

Terraform expects a single identity here instead of a list so it errors. Updating it to use the count index solves the issue.


```hcl 
resource "aws_ses_identity_policy" "default" {
  count    = var.enable_policy ? 1 : 0
  identity = aws_ses_domain_identity.default[count.index].arn
  name     = var.policy_name
  policy   = data.aws_iam_policy_document.document.json
}
```
anmolnagpal pushed a commit that referenced this issue Jul 28, 2022
Closes #16 

Previously: 

```hcl
resource "aws_ses_identity_policy" "default" {
  count    = var.enable_policy ? 1 : 0
  identity = aws_ses_domain_identity.default.*.arn
  name     = var.policy_name
  policy   = data.aws_iam_policy_document.document.json
}
```

Terraform expects a single identity here instead of a list so it errors. Updating it to use the count index solves the issue.


```hcl 
resource "aws_ses_identity_policy" "default" {
  count    = var.enable_policy ? 1 : 0
  identity = aws_ses_domain_identity.default[count.index].arn
  name     = var.policy_name
  policy   = data.aws_iam_policy_document.document.json
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants