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

IAM service-linked role creation fails for AWS China #10754

Closed
n1cholasgeorge opened this issue Nov 5, 2019 · 6 comments · Fixed by #11919
Closed

IAM service-linked role creation fails for AWS China #10754

n1cholasgeorge opened this issue Nov 5, 2019 · 6 comments · Fixed by #11919
Labels
bug Addresses a defect in current functionality. partition/aws-cn Pertains to the aws-cn partition. partition/aws-iso Pertains to the aws-iso partition. partition/aws-iso-b Pertains to the aws-iso-b partition. service/iam Issues and PRs that pertain to the iam service.
Milestone

Comments

@n1cholasgeorge
Copy link

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 "me too" comments, 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 Version

Terraform v0.12.13

  • provider.aws v2.34.0

Affected Resource(s)

Terraform v0.12.13

  • provider.aws v2.34.0

Terraform Configuration Files

resource "aws_iam_service_linked_role" "es" {
  aws_service_name = "es.cn-northwest-1.amazonaws.com.cn"
}

Debug Output

'''
https://gist.github.com/n1cholasgeorge/8dceb76d495784baeb54c19409ad3e5d
'''

Expected Behavior

Success

Actual Behavior

Error: "aws_service_name" must be a service URL e.g. elasticbeanstalk.amazonaws.com

Possibly due to the aws china endpoint address ending .com.cn

@ghost ghost added the service/iam Issues and PRs that pertain to the iam service. label Nov 5, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 5, 2019
@bflad bflad added bug Addresses a defect in current functionality. partition/aws-cn Pertains to the aws-cn partition. partition/aws-iso Pertains to the aws-iso partition. partition/aws-iso-b Pertains to the aws-iso-b partition. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 5, 2019
@bflad
Copy link
Contributor

bflad commented Nov 5, 2019

Hi @n1cholasgeorge 👋 Thank you for reporting this and sorry you ran into trouble with this resource.

The errant validation logic can be found here: https://github.com/terraform-providers/terraform-provider-aws/blob/f39af7fff691603f5dc5b553c618d1dbdb6ea0df/aws/resource_aws_iam_service_linked_role.go#L31-L38

If someone is interested in fixing this, my recommendation would be either allow all known suffixes (such as AWS Commercial/GovCloud (US) amazonaws.com, AWS China amazonaws.com.cn, AWS C2S c2s.ic.gov, and AWS SC2S sc2s.sgov.gov) or more preferably, just check for the presence of a period (.) since the idea behind this validation was to prevent mistakes such as just putting the service name (e.g. es):

				ValidateFunc: func(v interface{}, k string) (ws []string, es []error) {
					value := v.(string)
					if !strings.Contains(value, ".") {
						es = append(es, fmt.Errorf(
							"%q must be a full service hostname e.g. elasticbeanstalk.amazonaws.com", k))
					}
					return
				},

@ghost
Copy link

ghost commented Feb 3, 2020

I'm going to close this issue due to inactivity (90 days without response ⏳ ). This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost closed this as completed Feb 3, 2020
@bflad bflad reopened this Feb 5, 2020
bflad added a commit that referenced this issue Feb 5, 2020
…on to accept values in AWS partitions outside AWS Commercial and AWS GovCloud (US)

Reference: #10754

Output from acceptance testing:

```
--- PASS: TestAccAWSIAMServiceLinkedRole_basic (23.90s)
--- PASS: TestAccAWSIAMServiceLinkedRole_CustomSuffix (24.77s)
--- PASS: TestAccAWSIAMServiceLinkedRole_CustomSuffix_DiffSuppressFunc (25.00s)
--- PASS: TestAccAWSIAMServiceLinkedRole_Description (31.36s)
```
@bflad
Copy link
Contributor

bflad commented Feb 5, 2020

Submitted bug fix: #11919

bflad added a commit that referenced this issue Mar 3, 2020
…on to accept values in AWS partitions outside AWS Commercial and AWS GovCloud (US) (#11919)

Reference: #10754

Output from acceptance testing:

```
--- PASS: TestAccAWSIAMServiceLinkedRole_basic (23.90s)
--- PASS: TestAccAWSIAMServiceLinkedRole_CustomSuffix (24.77s)
--- PASS: TestAccAWSIAMServiceLinkedRole_CustomSuffix_DiffSuppressFunc (25.00s)
--- PASS: TestAccAWSIAMServiceLinkedRole_Description (31.36s)
```
@bflad bflad added this to the v2.52.0 milestone Mar 3, 2020
@bflad
Copy link
Contributor

bflad commented Mar 3, 2020

The fix for this has been merged and will release with version 2.52.0 of the Terraform AWS Provider, Thursday this week.

@ghost
Copy link

ghost commented Mar 6, 2020

This has been released in version 2.52.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 for triage. Thanks!

@ghost
Copy link

ghost commented Apr 2, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
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. partition/aws-cn Pertains to the aws-cn partition. partition/aws-iso Pertains to the aws-iso partition. partition/aws-iso-b Pertains to the aws-iso-b partition. service/iam Issues and PRs that pertain to the iam service.
Projects
None yet
2 participants