Skip to content

apigw-dynamodb-terraform: Update AWS Provider to v6#3073

Open
kakakakakku wants to merge 4 commits intoaws-samples:mainfrom
kakakakakku:apigw-dynamodb-terraform
Open

apigw-dynamodb-terraform: Update AWS Provider to v6#3073
kakakakakku wants to merge 4 commits intoaws-samples:mainfrom
kakakakakku:apigw-dynamodb-terraform

Conversation

@kakakakakku
Copy link
Copy Markdown
Contributor

Issue #, if available:
N/A

Description of changes:
Hi😀 Thanks for the useful patterns!

To keep this pattern maintainable, I updated the AWS Provider to v6 and replaced deprecated HCL code. I also fixed incorrect instructions in the README.

Check

terraform apply completed successfully and works good.

$ curl -H 'x-api-key: xxx' -H 'Content-Type: application/json' --request POST 'https://kl1vikew8a.execute-api.us-east-1.amazonaws.com/v1/pets' --data-raw '{ "PetType": "dog", "PetName": "tito", "PetPrice": 250 }'
{}

$ curl -H 'x-api-key: xxx' --request GET 'https://kl1vikew8a.execute-api.us-east-1.amazonaws.com/v1/pets/dog' | jq .
{
  "pets": [
    {
      "id": "f3667862-28d8-44cb-b4b6-c876a8991df9",
      "PetType": "dog",
      "PetName": "tito",
      "PetPrice": "250"
    }
  ]
}

Thank you😀


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

key_schema {
attribute_name = "PetType"
key_type = "HASH"
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash_key - (Optional, Deprecated) Name of the hash key in the index; must be defined as an attribute in the resource. Mutually exclusive with key_schema. Use key_schema instead.
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table

"credentials" : "${aws_iam_role.APIGWRole.arn}",
"httpMethod" : "POST",
"uri" : "arn:aws:apigateway:${data.aws_region.current.name}:dynamodb:action/PutItem",
"uri" : "arn:aws:apigateway:${data.aws_region.current.id}:dynamodb:action/PutItem",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: It deprecated from Provider v6

```
{
"music": [
"pets": [
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: The README file was incorrect, preventing the tests from running properly. I've fixed it👍

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 this pull request may close these issues.

3 participants