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_backup_region_settings: Element present in resource type opt in preference has invalid values #21801

Open
ohmer opened this issue Nov 16, 2021 · 5 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. new-data-source Introduces a new data source. service/backup Issues and PRs that pertain to the backup service.

Comments

@ohmer
Copy link

ohmer commented Nov 16, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

I have a module which contains the following:

variable "resource_type_opt_in_preference" {
  type = map(bool)

  default = {
    "Aurora"          = true
    "DocumentDB"      = true
    "DynamoDB"        = true
    "EBS"             = true
    "EC2"             = true
    "EFS"             = true
    "FSx"             = false
    "Neptune"         = false
    "RDS"             = true
    "Storage Gateway" = false
  }
}

resource "aws_backup_region_settings" "this" {
  resource_type_opt_in_preference = var.resource_type_opt_in_preference
}

It is part of a baseline and I would like it to apply to any region. It fails to apply in us-west-1 with the error message below:

│ Error: error setting Backup Region Settings (us-west-1): InvalidParameterValueException: Element present in resource type opt in preference has invalid values. Please use describeRegionSettings API to know the supported resource types
│ {
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "<REDACTED>"
│   },
│   Code_: "ERROR_41007",
│   Message_: "Element present in resource type opt in preference has invalid values. Please use describeRegionSettings API to know the supported resource types"
│ }

I believe the root cause is the list of service differs by region:

$ aws backup describe-region-settings --region us-west-1
{
    "ResourceTypeOptInPreference": {
        "Aurora": true,
        "DynamoDB": true,
        "EBS": true,
        "EC2": true,
        "EFS": true,
        "FSx": true,
        "Neptune": false,
        "RDS": true,
        "Storage Gateway": true
    }
}

DocumentDB is not in us-west-1 but is in us-east-1

$ aws backup describe-region-settings --region us-east-1
{
    "ResourceTypeOptInPreference": {
        "Aurora": false,
        "DocumentDB": false,
        "DynamoDB": true,
        "EBS": true,
        "EC2": true,
        "EFS": true,
        "FSx": false,
        "Neptune": false,
        "RDS": true,
        "Storage Gateway": true
    }
}

New or Affected Resource(s)

  • aws_backup_region_settings

Potential Terraform Configuration

Not tested but probably something like that:

variable "resource_type_opt_in_preference" {
  type = map(bool)

  default = {
    "Aurora"          = true
    "DocumentDB"      = true
    "DynamoDB"        = true
    "EBS"             = true
    "EC2"             = true
    "EFS"             = true
    "FSx"             = false
    "Neptune"         = false
    "RDS"             = true
    "Storage Gateway" = false
  }
}

data "aws_backup_region_settings" "this" {}

resource "aws_backup_region_settings" "this" {
  resource_type_opt_in_preference = matchkeys(
      values(var.resource_type_opt_in_preference),
      keys(var.resource_type_opt_in_preference),
      keys(data.aws_backup_region_settings.this.resource_type_opt_in_preference)
    )
  }
}

References

@ohmer ohmer added the enhancement Requests to existing resources that expand the functionality or scope. label Nov 16, 2021
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/backup Issues and PRs that pertain to the backup service. labels Nov 16, 2021
@justinretzolk
Copy link
Member

Hey @ohmer 👋 Thank you for taking the time to file this issue. In looking into it, it seems this is an error message coming back from the AWS API itself, rather than a bug within the provider (I suspect you've already deduced this). Based on the "potential Terraform configuration" section, it looks like you're interested in a new data source that uses the describeRegionSettings API to determine the supported settings; is that accurate?

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 18, 2021
@ohmer
Copy link
Author

ohmer commented Nov 19, 2021

Hey @justinretzolk ,

New data source, yes it is a suggestion. I thought that silently handling this inside the resource would be less ideal. What do you think?

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Nov 19, 2021
@ewbankkit ewbankkit added the new-data-source Introduces a new data source. label Dec 8, 2021
@snmason
Copy link

snmason commented Mar 27, 2023

Bumping as I am hitting the same issue. Has a work around been found?

@lpiob
Copy link

lpiob commented May 12, 2023

It seems that the available settings are different for different regions. For example Timestream at this moment can be set for eu-west-1 but not for eu-west-3.

Skipping this setting causes perpetual change to be displayed in eu-west-1.
Including this setting causes an error on apply in eu-west-3.

@or-shachar
Copy link

I've started working on this feature that might at least answer the perpetual change issue.
#33993

Unfortunately I'm not at capacity to get into the acceptance testing framework.
If anyone would like to give me direction of missing pieces - would really appreciate it ✌️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. new-data-source Introduces a new data source. service/backup Issues and PRs that pertain to the backup service.
Projects
None yet
Development

No branches or pull requests

6 participants