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

[Bug]: aws_emr_cluster Inappropriate value for attribute "configurations": string required. #39959

Open
devlatte opened this issue Oct 31, 2024 · 3 comments
Labels
documentation Introduces or discusses updates to documentation. good first issue Call to action for new contributors looking for a place to start. Smaller or straightforward issues. service/emr Issues and PRs that pertain to the emr service.

Comments

@devlatte
Copy link

Terraform Core Version

1.9.8

AWS Provider Version

5.69.0

Affected Resource(s)

While working with EMR, I followed the Terraform guide but encountered an error:
Incorrect attribute value type about configurations in aws_emr_cluster.

Could you please confirm this?
I would prefer to use this option as it's more readable than configurations_json.

Expected Behavior

working well

Actual Behavior

Incorrect attribute value type occured

Relevant Error/Panic Output Snippet

╷
│ Error: Incorrect attribute value type
│
│   on adhoc_spark.tf line 47, in resource "aws_emr_cluster" "emr_adhoc_spark":
│   47:   configurations = [
│   48:     {
│   49:       classification = "spark-defaults"
│   50:       properties = {
│   51:         "spark.dynamicAllocation.enabled"   = "false"
│   52:         "spark.executor.memory"             = "4g"
│   53:         "spark.emr.default.executor.memory" = "4g"
│   54:         "spark.sql.session.timeZone"        = "Asia/Seoul"
│   55:       }
│   56:     },
│   57:     {
│   58:       classification = "spark-hive-site"
│   59:       properties = {
│   60:         "hive.metastore.client.factory.class" = "com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory"
│   61:       }
│   62:     }
│   63:   ]
│
│ Inappropriate value for attribute "configurations": string required.
╵

Terraform Configuration Files

resource "aws_emr_cluster" "emr_adhoc_spark" {
  ...
  configurations = [
    {
      classification = "spark-defaults"
      properties = {
        "spark.dynamicAllocation.enabled"   = "false"
        "spark.executor.memory"             = "4g"
        "spark.emr.default.executor.memory" = "4g"
        "spark.sql.session.timeZone"        = "Asia/Seoul"
      }
    },
    {
      classification = "spark-hive-site"
      properties = {
        "hive.metastore.client.factory.class" = "com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory"
      }
    }
  ]
}

Steps to Reproduce

  1. write emr configuration
  2. execute terraform plan

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

https://github.com/hashicorp/terraform-provider-aws/blob/main/internal/service/emr/cluster.go#L308

Would you like to implement a fix?

None

@devlatte devlatte added the bug Addresses a defect in current functionality. label Oct 31, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/emr Issues and PRs that pertain to the emr service. needs-triage Waiting for first response or review from a maintainer. labels Oct 31, 2024
@justinretzolk
Copy link
Member

Hey @devlatte 👋 Thank you for taking the time to raise this! I took a look over the documentation and found it a bit confusing as well, so I took a look through the relevant parts of the source code and the test cases and found that the expectation for the configurations argument is that the string will either point to a local file or to a URL containing the configuration data. It definitely seems like the documentation for that argument could use a bit of touching up to make that more clear.

On the other hand, your sample configuration could be made to work with configurations_json by using jsonencode():

resource "aws_emr_cluster" "emr_adhoc_spark" {
  # ...other config...

  configurations_json = jsonencode([
    {
      classification = "spark-defaults"
      properties = {
        "spark.dynamicAllocation.enabled"   = "false"
        "spark.executor.memory"             = "4g"
        "spark.emr.default.executor.memory" = "4g"
        "spark.sql.session.timeZone"        = "Asia/Seoul"
      }
    },
    {
      classification = "spark-hive-site"
      properties = {
        "hive.metastore.client.factory.class" = "com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory"
      }
    }
  ])
}

@justinretzolk justinretzolk added documentation Introduces or discusses updates to documentation. good first issue Call to action for new contributors looking for a place to start. Smaller or straightforward issues. and removed bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Oct 31, 2024
@devlatte
Copy link
Author

devlatte commented Nov 1, 2024

Hi @justinretzolk
Managing it with a file is a good option, and the jsonencode() method seems useful too.
Both methods seem like better options than a JSON string :)
I'll try applying it.
Thanks for the reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Introduces or discusses updates to documentation. good first issue Call to action for new contributors looking for a place to start. Smaller or straightforward issues. service/emr Issues and PRs that pertain to the emr service.
Projects
None yet
Development

No branches or pull requests

2 participants