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

r/aws_ssm_parameter: Fix import with version #37832

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/37832.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_ssm_parameter: Fix `Cannot import non-existent remote object` errors when importing resources with version
```
2 changes: 1 addition & 1 deletion internal/service/ssm/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func resourceParameterRead(ctx context.Context, d *schema.ResourceData, meta int
return sdkdiag.AppendErrorf(diags, "invalid configuration, cannot set type = %s and insecure_value", param.Type)
}

detail, err := findParameterMetadataByName(ctx, conn, d.Id())
detail, err := findParameterMetadataByName(ctx, conn, d.Get(names.AttrName).(string))

if !d.IsNewResource() && tfresource.NotFound(err) {
log.Printf("[WARN] SSM Parameter %s not found, removing from state", d.Id())
Expand Down
10 changes: 10 additions & 0 deletions internal/service/ssm/parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ func TestAccSSMParameter_basic(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"overwrite"},
},
// Test import with version.
// https://github.com/hashicorp/terraform-provider-aws/issues/37812.
{
ResourceName: resourceName,
ImportState: true,
ImportStateId: name + ":1",
ImportStateVerify: true,
ImportStateVerifyIdentifierAttribute: names.AttrName,
ImportStateVerifyIgnore: []string{names.AttrID, "overwrite"},
},
},
})
}
Expand Down
Loading