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

New resource for AppStream Stack Fleet Association #21484

Merged
merged 15 commits into from
Nov 24, 2021

Conversation

coderGo93
Copy link
Contributor

@coderGo93 coderGo93 commented Oct 25, 2021

Added a new resource, doc and tests for AppStream Stack Fleet Association called aws_appstream_stack_fleet_association

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #6508

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAppStreamFleetStackAssociation' PKG_NAME=internal/service/appstream
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/appstream/... -v -count 1 -parallel 20 -run=TestAccAppStreamFleetStackAssociation -timeout 180m
=== RUN   TestAccAppStreamFleetStackAssociation_basic
=== PAUSE TestAccAppStreamFleetStackAssociation_basic
=== RUN   TestAccAppStreamFleetStackAssociation_disappears
=== PAUSE TestAccAppStreamFleetStackAssociation_disappears
=== CONT  TestAccAppStreamFleetStackAssociation_basic
=== CONT  TestAccAppStreamFleetStackAssociation_disappears
--- PASS: TestAccAppStreamFleetStackAssociation_basic (1096.79s)
--- PASS: TestAccAppStreamFleetStackAssociation_disappears (1176.52s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/appstream  1178.602s

...

@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/appstream Issues and PRs that pertain to the appstream service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. needs-triage Waiting for first response or review from a maintainer. size/XL Managed by automation to categorize the size of a PR. labels Oct 25, 2021
@justinretzolk justinretzolk added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 25, 2021
@gdavison gdavison mentioned this pull request Nov 8, 2021
8 tasks
@gdavison gdavison self-assigned this Nov 8, 2021
Copy link
Contributor

@gdavison gdavison left a 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

Comment on lines 82 to 99
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))
}
Copy link
Contributor

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) {
Copy link
Contributor

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

"aws_appstream_fleet": appstream.ResourceFleet(),
"aws_appstream_image_builder": appstream.ResourceImageBuilder(),
"aws_appstream_stack": appstream.ResourceStack(),
"aws_appstream_stack_fleet_association": appstream.ResourceStackFleetAssociation(),
Copy link
Contributor

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")
Copy link
Contributor

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),
Copy link
Contributor

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

@github-actions github-actions bot added the generators Relates to code generators. label Nov 24, 2021
Copy link
Contributor

@gdavison gdavison left a 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)

@gdavison gdavison merged commit d398b6b into hashicorp:main Nov 24, 2021
@github-actions github-actions bot added this to the v3.67.0 milestone Nov 24, 2021
@github-actions
Copy link

github-actions bot commented Dec 1, 2021

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!

@github-actions
Copy link

github-actions bot commented Jun 7, 2022

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. generators Relates to code generators. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/appstream Issues and PRs that pertain to the appstream service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants