Git Product home page Git Product logo

Comments (7)

kadrach avatar kadrach commented on September 28, 2024 1
resource "awscc_dynamodb_table" "main" {
  table_name = "dynamodb_table_name"
  key_schema = {
    attribute_name = "UserId"
    key_type       = "HASH"
  }

  attribute_definitions = [{
    attribute_name = "UserId"
    attribute_type = "S"
  }]

  billing_mode = "PAY_PER_REQUEST"
}
rg "CloudControl DesiredState" output.log | jq '.value | fromjson'                                            
{
  "AttributeDefinitions": [
    {
      "AttributeName": "UserId",
      "AttributeType": "S"
    }
  ],
  "BillingMode": "PAY_PER_REQUEST",
  "KeySchema": {
    "attribute_name": "UserId",          # ⚠️ 
    "key_type": "HASH"                   # ⚠️ 
  },
  "TableName": "dynamodb_table_name"
}

With key_schema being treated as a map(string) the translator does not translate the Terraform names back to CloudFormation names.

from terraform-provider-awscc.

quixoticmonk avatar quixoticmonk commented on September 28, 2024 1

@wellsiau-aws The current working version of the schema is below. The original example has an incorrect sse_type of AWSKMS.

  • The current schema enforces the members of key_schema to match the attribute_definitions which is from the expectation on the AWS::DynamoDB::Table spec. This shouldn't be the case.
  • key_schema is expecting a JSON string format and doesn't take the snake cased arguments.
resource "awscc_dynamodb_table" "main" {
  table_name = "dynamodb_table_name"
  key_schema = jsonencode([{
    AttributeName = "UserId"
    KeyType       = "HASH"
  }])

  attribute_definitions = [{
    attribute_name = "UserId"
    attribute_type = "S"
    }]

  billing_mode = "PROVISIONED"
  provisioned_throughput = {
    read_capacity_units  = 20
    write_capacity_units = 20
  }
  deletion_protection_enabled = true
  sse_specification = {
    sse_enabled = true
    sse_type    = "KMS"
  }


  time_to_live_specification = {
    attribute_name = "TimeToExist"
    enabled        = false
  }
  table_class = "STANDARD"

  tags = [{
    key   = "Modified By"
    value = "AWSCC"
  }]
}

from terraform-provider-awscc.

wellsiau-aws avatar wellsiau-aws commented on September 28, 2024 1

@kadrach @quixoticmonk thank you for your input!

I believe there are two separate problem here:

  1. key_schema attribute being treated as map(string) as described here
  2. CCAPI write handler requires that key_schema attribute value to matches the attribute_definitions as described here

@quixoticmonk , I suggest to open a new issue to record your problem since that also another upstream AWS issue.

from terraform-provider-awscc.

wellsiau-aws avatar wellsiau-aws commented on September 28, 2024

Key Schema object:

"KeySchema": {
"type": "object",
"additionalProperties": false,
"properties": {
"AttributeName": {
"type": "string"
},
"KeyType": {
"type": "string"
}
},
"required": [
"KeyType",
"AttributeName"
]

from terraform-provider-awscc.

wellsiau-aws avatar wellsiau-aws commented on September 28, 2024

AWSCC handler for DynamoDB Table: https://github.com/hashicorp/terraform-provider-awscc/blob/ce1ad5105c8f463339880e0dd2d00395cd2f40a6/internal/aws/dynamodb/table_resource_gen.go#L472C1-L474C22

Notice how the element type is string

		"key_schema": schema.MapAttribute{ /*START ATTRIBUTE*/
			ElementType: types.StringType,
			Required:    true,

from terraform-provider-awscc.

wellsiau-aws avatar wellsiau-aws commented on September 28, 2024

Perhaps this part of the Key Schema is causing confusion on the auto-generation because it declare either an array or an object.

"KeySchema": {
"oneOf": [
{
"type": "array",
"uniqueItems": true,
"items": {
"$ref": "#/definitions/KeySchema"
}
},
{
"type": "object"
}
]
},

from terraform-provider-awscc.

novekm avatar novekm commented on September 28, 2024

Having this error too in latest version of provider (0.55.0)

from terraform-provider-awscc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.