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: Override role on RolePolicy to accept a Role #278

Merged
merged 1 commit into from
Jul 19, 2018

Conversation

jen20
Copy link
Contributor

@jen20 jen20 commented Jul 17, 2018

This brings RolePolicy in line with RolePolicyAttachment in accepting a Role rather than requiring the ID as a string.

Copy link
Contributor

@ellismg ellismg left a comment

Choose a reason for hiding this comment

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

I think we might want to do this a different way if possible to avoid breaking our API.

resources.go Outdated
"aws_iam_role_policy": {
Tok: awsResource(iamMod, "RolePolicy"),
Fields: map[string]*tfbridge.SchemaInfo{
"role": {Type: awsType(iamMod+"/role", "Role")},
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume doing this is a breaking change? Could we instead use the AltTypes technology to project the argument as Input<string> | Input<Role>? I believe that would work as expected because we'd marshal the Role by taking the ID of the custom resource, which is what the string here is logically?

/cc @lukehoban

Copy link
Member

Choose a reason for hiding this comment

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

I was in fact just talking to @pgavlin about this sort of thing yesterday, as the places where we have strong types can trip up the HCL converter. I believe anywhere we add schema types that aren't just string typedefs, we should do what Matt is suggesting, so we can still accept strings.

Copy link
Member

@joeduffy joeduffy Jul 17, 2018

Choose a reason for hiding this comment

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

This has the nice consequence that the dozens (hundreds?) of places we've not yet added the strong typing can be patched up incrementally over time without any breaking changes, something I'm eager to do because I love having the strong types.

Copy link
Contributor

@lukehoban lukehoban Jul 17, 2018

Choose a reason for hiding this comment

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

Yes - we should use AltTypes here to avoid the breaking change. We should ideally do the same in the existing places where Role is used as a strongly typed override.

An example of the "right" pattern is here:

pulumi-aws/resources.go

Lines 437 to 442 in 44eed4b

"alarm_actions": {
Elem: &tfbridge.SchemaInfo{
Type: "string",
AltTypes: []tokens.Type{awsResource(snsMod, "Topic")},
},
},
.

This is a good reminder to write up the API guidelines for these projections - we made a set of decisions about a handful of related topics a few months back but doesn't appears we ever fully documented that. Opened https://github.com/pulumi/pulumi-terraform/issues/209 to track.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we use AltTypes, does everything underneath just do the "right thing", or does it need additional changes?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you do similar to the alarm_actions example above, everything else should “just work”.

@jen20 jen20 force-pushed the role-policy-accept-role branch from 1681ec3 to 8c5a062 Compare July 17, 2018 19:12
This brings RolePolicy in line with RolePolicyAttachment in accepting a
Role rather than requiring the ID.
@jen20 jen20 force-pushed the role-policy-accept-role branch from 8c5a062 to 41e258f Compare July 17, 2018 19:18
@jen20
Copy link
Contributor Author

jen20 commented Jul 17, 2018

@ellismg I think that latest round of changes should fix this - there was a spurious CI failure which looked network related, but re-kicking the build seems to work OK.

Copy link
Contributor

@ellismg ellismg left a comment

Choose a reason for hiding this comment

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

LGTM.

@ellismg ellismg merged commit 756c601 into pulumi:master Jul 19, 2018
@ellismg
Copy link
Contributor

ellismg commented Jul 19, 2018

Thanks @jen20!

@jen20 jen20 deleted the role-policy-accept-role branch July 19, 2018 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants