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

Add support for service-linked roles #921

Closed
sshvetsov opened this issue Jun 20, 2017 · 9 comments · Fixed by #2985
Closed

Add support for service-linked roles #921

sshvetsov opened this issue Jun 20, 2017 · 9 comments · Fixed by #2985
Labels
new-resource Introduces a new resource. service/iam Issues and PRs that pertain to the iam service.
Milestone

Comments

@sshvetsov
Copy link

AWS recently introduced "service-linked roles" - a more secure way of delegating permissions to other AWS services. Trust policy of such roles cannot be modified and only the linked service can assume such role.

Use Case

These roles are especially useful in AWS accounts where "powerful" services like CloudFormation, Elastic Beanstalk, etc. are used, but IAM admin wants to reduce chances of users/instances assuming traditional service roles.

Implementation

I'm not sure whether this an enhancement to existing aws_iam_role resource or best be treated as a new resource. While output of the API is the same Role object, API input parameters are different. It might be more straightforward for end users to create/import and configure this as a separate resource, especially since it cannot be attached to instance profile or assumed by principals other than AWS service.

References

@tv-17
Copy link

tv-17 commented Aug 11, 2017

Hi,

Any update on this?

@apparentlymart apparentlymart added the enhancement Requests to existing resources that expand the functionality or scope. label Aug 11, 2017
@apparentlymart
Copy link
Member

Given the very different interface for CreateServiceLinkedRole compared to the general CreateRole, I think a new resource makes sense here. Ideally it'd export the attributes of the resulting role object using the same attribute names and types as aws_role uses for input, so that interpolations for attributes of both will be as similar as possible.

resource "aws_iam_service_linked_role" "example" {
  aws_service_name = "elasticbeanstalk.amazonaws.com"
}

resource "aws_iam_role_policy" "example" {
  name = "example"
  role = "${aws_iam_service_linked_role.example.name}"

  policy = ...
}

output "role_arn" {
  value = "${aws_iam_service_linked_role.example.arn}"
}

The Terraform team at HashiCorp is not currently working on this particular issue. It's likely that we'll get to it at some point since it's a good general UX improvement for using a lot of AWS services -- how to write working assume role policies is a very common question! However, if someone else has the time and motivation to work on this sooner we'd be happy to review a PR for it.

@jammycakes
Copy link

It should be noted that service-linked roles are automatically created. Also, in at least some cases (certainly, for aws_appautoscaling_target), AWS also insists on overriding your choice of role and using the service-linked role instead. This has meant that newly created aws_appautoscaling_target resources are appearing as tainted every time.

@bflad bflad added service/iam Issues and PRs that pertain to the iam service. new-resource Introduces a new resource. and removed enhancement Requests to existing resources that expand the functionality or scope. labels Jan 18, 2018
@bashoKa
Copy link

bashoKa commented Feb 7, 2018

Cloudwatch events are affected as well:
does not create AWSServiceRoleForCloudWatchEvents.
terraform 0.11.2

@toddbluhm
Copy link

I just ran into this issue trying to setup a new ecs service. I cannot assign a regular role to a new ecs service anymore, it requires a service linked role.

@ungureanuvladvictor
Copy link
Contributor

+1 to this, would be something really useful.

@bflad bflad added this to the v1.15.0 milestone Apr 11, 2018
@bflad
Copy link
Member

bflad commented Apr 11, 2018

The initial aws_iam_service_linked_role resource has been merged into master and will release with v1.15.0 of the AWS provider, likely in a week. 🎉

@bflad
Copy link
Member

bflad commented Apr 18, 2018

This has been released in version 1.15.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 6, 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!

@hashicorp hashicorp locked and limited conversation to collaborators Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource. service/iam Issues and PRs that pertain to the iam service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants