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

Resolves issue with importing an aws_ecs_service with an iam role that has a non-default path with multiple slashes #30170

Merged
merged 14 commits into from
Apr 14, 2023

Conversation

curator
Copy link
Contributor

@curator curator commented Mar 21, 2023

Description

Resolves an issue with importing an aws_ecs_service with an IAM role that has a non-default path with multiple slashes, such as arn:aws:iam::123456789012:role/role_group/role_name. Modifies the split for ARNs to handle ones with multiple slashes, by splitting the string into two components on the first slash.

Relations

Closes #30161

References

Output from Acceptance Testing

~/Documents/gitrepos/golang/src/github.com/terraform-providers/terraform-provider-aws ᐅ make testacc TESTS=TestAccECSService_iamRole PKG=ecs
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecs/... -v -count 1 -parallel 20 -run='TestAccECSService_iamRole'  -timeout 180m
=== RUN   TestAccECSService_iamRole
=== PAUSE TestAccECSService_iamRole
=== CONT  TestAccECSService_iamRole
--- PASS: TestAccECSService_iamRole (66.75s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecs	71.379s

…splitting the string into two components on the first slash
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. service/ecs Issues and PRs that pertain to the ecs service. labels Mar 21, 2023
@breathingdust breathingdust added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Apr 6, 2023
@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/S Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Apr 14, 2023
@github-actions github-actions bot added size/M Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Apr 14, 2023
@jar-b jar-b merged commit 4da4e61 into hashicorp:main Apr 14, 2023
@github-actions github-actions bot added this to the v4.64.0 milestone Apr 14, 2023
@jar-b
Copy link
Member

jar-b commented Apr 14, 2023

Thanks for your contribution, @curator! 👏

I noticed that the ECS APIs expect role names with paths to include the leading /, so I adjusted the helper functions a bit to separate the role and cluster ARN logic.

If your specified role has a path other than /, then you must either specify the full role ARN (this is recommended) or prefix the role name with the path. For example, if a role with the name bar has a path of /foo/ then you would specify /foo/bar as the role name.

https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html#ECS-CreateService-request-role

Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

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

$ make testacc PKG=ecs TESTS=TestAccECSService_
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecs/... -v -count 1 -parallel 20 -run='TestAccECSService_'  -timeout 180m

--- PASS: TestAccECSService_PlacementStrategy_missing (3.59s)
=== CONT  TestAccECSService_ServiceConnect_ingressPortOverride
--- PASS: TestAccECSService_DaemonSchedulingStrategy_setDeploymentMinimum (37.54s)
=== CONT  TestAccECSService_deploymentCircuitBreaker
--- PASS: TestAccECSService_DaemonSchedulingStrategy_basic (37.66s)
=== CONT  TestAccECSService_forceNewDeployment
--- PASS: TestAccECSService_Tags_propagate (74.00s)
=== CONT  TestAccECSService_multipleTargetGroups
--- PASS: TestAccECSService_replicaSchedulingStrategy (80.92s)
=== CONT  TestAccECSService_alb
--- PASS: TestAccECSService_PlacementConstraints_basic (84.81s)
=== CONT  TestAccECSService_clusterName
--- PASS: TestAccECSService_forceNewDeploymentTriggers (85.06s)
=== CONT  TestAccECSService_loadBalancerChanges
--- PASS: TestAccECSService_executeCommand (85.25s)
=== CONT  TestAccECSService_PlacementConstraints_emptyExpression
--- PASS: TestAccECSService_LaunchTypeEC2_network (91.77s)
=== CONT  TestAccECSService_CapacityProviderStrategy_update
--- PASS: TestAccECSService_Tags_managed (92.00s)
=== CONT  TestAccECSService_iamRole
--- PASS: TestAccECSService_basic (95.35s)
=== CONT  TestAccECSService_healthCheckGracePeriodSeconds
--- PASS: TestAccECSService_Tags_basic (95.49s)
=== CONT  TestAccECSService_renamedCluster
--- PASS: TestAccECSService_PlacementStrategy_basic (103.50s)
=== CONT  TestAccECSService_familyAndRevision
--- PASS: TestAccECSService_deploymentCircuitBreaker (72.41s)
=== CONT  TestAccECSService_CapacityProviderStrategy_multiple
--- PASS: TestAccECSService_forceNewDeployment (92.26s)
=== CONT  TestAccECSService_ServiceConnect_full
--- PASS: TestAccECSService_iamRole (44.37s)
=== CONT  TestAccECSService_ServiceRegistries_container
--- PASS: TestAccECSService_LaunchTypeFargate_platformVersion (147.44s)
=== CONT  TestAccECSService_ServiceRegistries_changes
--- PASS: TestAccECSService_PlacementConstraints_emptyExpression (69.11s)
=== CONT  TestAccECSService_PlacementStrategy_unnormalized
--- PASS: TestAccECSService_LaunchTypeFargate_waitForSteadyState (158.95s)
=== CONT  TestAccECSService_CapacityProviderStrategy_forceNewDeployment
--- PASS: TestAccECSService_LaunchTypeFargate_updateWaitForSteadyState (159.05s)
=== CONT  TestAccECSService_CapacityProviderStrategy_basic
--- PASS: TestAccECSService_clusterName (79.61s)
=== CONT  TestAccECSService_ServiceRegistries_basic
--- PASS: TestAccECSService_ServiceConnect_basic (166.79s)
=== CONT  TestAccECSService_disappears
--- PASS: TestAccECSService_LaunchTypeFargate_basic (167.50s)
=== CONT  TestAccECSService_Alarms
--- PASS: TestAccECSService_ServiceConnect_ingressPortOverride (165.98s)
=== CONT  TestAccECSService_DeploymentValues_minZeroMaxOneHundred
--- PASS: TestAccECSService_familyAndRevision (66.36s)
=== CONT  TestAccECSService_DeploymentValues_basic
--- PASS: TestAccECSService_renamedCluster (77.14s)
=== CONT  TestAccECSService_DeploymentControllerType_external
--- PASS: TestAccECSService_ServiceConnect_remove (174.91s)
=== CONT  TestAccECSService_basicImport
--- PASS: TestAccECSService_PlacementStrategy_unnormalized (58.92s)
=== CONT  TestAccECSService_DeploymentControllerType_codeDeployUpdateDesiredCountAndHealthCheckGracePeriod
--- PASS: TestAccECSService_DeploymentControllerType_external (50.64s)
--- PASS: TestAccECSService_CapacityProviderStrategy_multiple (113.98s)
--- PASS: TestAccECSService_DeploymentValues_minZeroMaxOneHundred (59.54s)
--- PASS: TestAccECSService_DeploymentValues_basic (59.36s)
--- PASS: TestAccECSService_Alarms (69.40s)
--- PASS: TestAccECSService_DeploymentControllerType_codeDeploy (241.62s)
--- PASS: TestAccECSService_CapacityProviderStrategy_forceNewDeployment (98.72s)
--- PASS: TestAccECSService_alb (190.00s)
--- PASS: TestAccECSService_loadBalancerChanges (193.03s)
--- PASS: TestAccECSService_ServiceConnect_full (157.90s)
--- PASS: TestAccECSService_ServiceRegistries_container (153.04s)
--- PASS: TestAccECSService_multipleTargetGroups (222.40s)
--- PASS: TestAccECSService_ServiceRegistries_basic (153.27s)
--- PASS: TestAccECSService_CapacityProviderStrategy_basic (164.07s)
--- PASS: TestAccECSService_healthCheckGracePeriodSeconds (241.89s)
--- PASS: TestAccECSService_disappears (178.06s)
--- PASS: TestAccECSService_CapacityProviderStrategy_update (263.53s)
--- PASS: TestAccECSService_basicImport (203.28s)
--- PASS: TestAccECSService_ServiceRegistries_changes (255.35s)
--- PASS: TestAccECSService_DeploymentControllerType_codeDeployUpdateDesiredCountAndHealthCheckGracePeriod (388.50s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ecs        604.830s

@github-actions
Copy link

This functionality has been released in v4.64.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

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 May 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service. size/M 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.

[Bug]: import aws_ecs_service results in destroying existing service
3 participants