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

provider/aws: Add arn attribute for DynamoDB tables #2924

Merged
merged 1 commit into from
Aug 5, 2015

Conversation

calvinfo
Copy link

@calvinfo calvinfo commented Aug 3, 2015

This commit exports the arn as well as the id, since IAM
roles require the full resource name rather than just the table
name. I'd even be in favor or having arn as the id since the
<region, tablename> pair is the uniqueness constraint, but this
will keep backwards compatibility:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateTable.html

Feedback appreciated :)

This commit exports the `arn` as well as the `id`, since IAM
roles require the full resource name rather than just the table
name. I'd even be in favor or having `arn` as the `id` since the
<region, tablename> pair is the uniqueness constraint, but this
will keep backwards compatibility:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateTable.html
@@ -283,6 +283,7 @@ func resourceAwsDynamoDbTableCreate(d *schema.ResourceData, meta interface{}) er
} else {
// No error, set ID and return
d.SetId(*output.TableDescription.TableName)
d.Set("arn", *output.TableDescription.TableARN)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious, does this work without specifying arn in the schema? I think arn needs to be defined above, like the Kinesis resource (though you can omit the optional and just leave it as computed).

@catsby catsby added the waiting-response An issue/pull request is waiting for a response from the community label Aug 5, 2015
@catsby
Copy link
Contributor

catsby commented Aug 5, 2015

Thanks for the contribution! I noted in-line, but I think we need two things here. First, we need the arn in the schema:

Schema: map[string]*schema.Schema{
    "arn": &schema.Schema{
        Type:     schema.TypeString,
        Computed: true,
    },
    "name": &schema.Schema{
    [...]

Second, let's move the d.Set into the read method, so that existing Dynamo resources will pick up the ARN on the next refresh. Remove your current d.Set("arn") and add this line just before the return nil in resourceAwsDynamoDbTableRead:

d.Set("arn", table.TableARN)

Then we're good to go!

@catsby
Copy link
Contributor

catsby commented Aug 5, 2015

Going to go ahead and pull this in, and make those modifications myself. Thanks again!

catsby added a commit that referenced this pull request Aug 5, 2015
provider/aws: Add arn attribute for DynamoDB tables
@catsby catsby merged commit b779144 into hashicorp:master Aug 5, 2015
@catsby
Copy link
Contributor

catsby commented Aug 5, 2015

Said changes: a1a78bd

@calvinfo
Copy link
Author

calvinfo commented Aug 5, 2015

Whoop, good catch! Thanks for making the changes!

@ghost
Copy link

ghost commented May 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement provider/aws waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants