-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
New resource for AppStream Stack Fleet Association #21484
New resource for AppStream Stack Fleet Association #21484
Conversation
89c83ef
to
8e9b8f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @coderGo93, a few changes to make
resp, err := conn.ListAssociatedStacksWithContext(ctx, &appstream.ListAssociatedStacksInput{FleetName: aws.String(fleetName)}) | ||
|
||
if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, appstream.ErrCodeResourceNotFoundException) { | ||
log.Printf("[WARN] Appstream Stack Fleet Association (%s) not found, removing from state", d.Id()) | ||
d.SetId("") | ||
return nil | ||
} | ||
|
||
var sName string | ||
for _, name := range resp.Names { | ||
if aws.StringValue(name) == stackName { | ||
sName = aws.StringValue(name) | ||
} | ||
} | ||
|
||
if err != nil { | ||
return diag.FromErr(fmt.Errorf("error reading Appstream Stack Fleet Association (%s): %w", d.Id(), err)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this basic set of code is used once here and twice in the tests, it could be made a separate finder function. Like the finder function in #21485, it should return a resource.NotFoundError
if the matching association is not found.
return nil | ||
} | ||
|
||
func DecodeStackFleetID(id string) (string, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have an associated ID encoding function
internal/provider/provider.go
Outdated
"aws_appstream_fleet": appstream.ResourceFleet(), | ||
"aws_appstream_image_builder": appstream.ResourceImageBuilder(), | ||
"aws_appstream_stack": appstream.ResourceStack(), | ||
"aws_appstream_stack_fleet_association": appstream.ResourceStackFleetAssociation(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this associates a stack with with a fleet, this should be renamed to aws_appstream_fleet_stack_association
. The files and resource functions should be renamed to match.
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
acctest.PreCheck(t) | ||
acctest.PreCheckHasIAMRole(t, "AmazonAppStreamServiceAccess") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating this resource doesn't require this IAM role, so the check can be removed
{ | ||
Config: testAccStackFleetAssociationConfig(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckStackFleetAssociationExists(resourceName), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests should check the values of the parameters
9b94146
to
24e505e
Compare
18ceff9
to
074803a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @coderGo93. I've made some adjustments.
Acceptance test results
--- PASS: TestAccAppStreamFleetStackAssociation_basic (835.05s)
--- PASS: TestAccAppStreamFleetStackAssociation_disappears (952.72s)
This functionality has been released in v3.67.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Added a new resource, doc and tests for AppStream Stack Fleet Association called
aws_appstream_stack_fleet_association
Community Note
Relates #6508
Output from acceptance testing: