terraform-provider-aws: aws_appstream_fleet_stack_association not working correctly
Community Note
- Please vote on this issue by adding a š reaction to the original issue 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 issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform CLI and Terraform AWS Provider Version
Affected Resource(s)
aws_appstream_fleet_stack_association
Terraform Configuration Files
The example provided here does not seem to create an aws_appstream_fleet_stack_association in the state, yet the association itself seems to be created in AWS.
resource "aws_appstream_stack" "stack" {
count = local.appstream.create_as ? 1 : 0
name = "Stack"
tags = local.tags
}
resource "aws_appstream_fleet" "fleet" {
count = local.appstream.create_as ? 1 : 0
name = "Fleet"
image_name = "Firefox-Image"
instance_type = "stream.standard.small"
idle_disconnect_timeout_in_seconds = 3600
enable_default_internet_access = false
fleet_type = "ALWAYS_ON"
compute_capacity {
desired_instances = 2
}
vpc_config {
subnet_ids = module.vpc.private_subnets
}
tags = local.tags
}
resource "aws_appstream_fleet_stack_association" "stack_fleet" {
count = local.appstream.create_as ? 1 : 0
fleet_name = aws_appstream_fleet.fleet.0.name
stack_name = aws_appstream_stack.stack.0.name
}
Expected Behavior
The association should be created in the state
Actual Behavior
Terraform believes that the association was not created in a subsequent run, and then tries to create it - but finds that it already exists. You then have to import the resource manually.
If you then update or taint a stack, there appears to be a missing dependency to re-create the association.
Steps to Reproduce
- Create the resources in the example or the above code.
- Update the stack definition or taint it.
- Try to apply it
Output (new resource)
Error: error reading AppStream Fleet Stack Association (Stack/Fleet): No stack "Fleet" associated with fleet "Stack"
Output (updating stack resource)
aws_appstream_stack.stack[0]: Destroying... [id=Stack]
Error: error deleting Appstream Stack (Stack): ResourceInUseException: Cannot delete stack Stack. This stack has fleets associated with it. Only stacks with no fleets associated with it can be deleted.
Looking at the creating a resource error output, it looks like āfleet_nameā and āstack_nameā are somehow inverted somewhere in the logic. I have double checked my references and they are correct - which leads me to believe they might be swapped in the logic of the provider somehwereā¦
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 28
- Comments: 19
Commits related to this issue
- refactor — committed to hashicorp/terraform-provider-aws by coderGo93 3 years ago
This worked for me⦠But we really need a permanent fix. Itās only one line of code š
I have the same issue using: hashicorp/aws v4.6.0
Error: error reading AppStream Fleet Stack Association (AppStreamStack/wav-dev-asf): No stack "wav-dev-asf" associated with fleet "AppStreamStack"Any update on this, please?
I have encountered this issue as well. Hoping for a fix
FYI: I sent an email with details to one of the contributors of the commit that caused this issue. Hopefully they will respond. I will create a PR if neededā¦
Moved my comment from the duplicate issue.
The bug seems to be caused by this line: https://github.com/hashicorp/terraform-provider-aws/blob/60bd245a93893c6eefae9a84f72f3a22ed7c2305/internal/service/appstream/fleet_stack_association.go#L69
Where the arguments to
EncodeStackFleetIDare not in the right order.The function for reference:
A temporary workaround (until this bug is fixed), that Iām testing is:
EDIT: from testing, this works some times, but itās still flaky with some inconsistent terraform state errors.
I am facing the exact issue! any solution to resolve this issue?
This functionality has been released in v4.21.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!
facing the same error,any fix for thisā¦