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

Change policyArns in RoleWithPolicyArgs to accept eventual types #1276

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

flostadler
Copy link
Contributor

Previously the policyArns attribute in RoleWithPolicyArgs only accepted plain types as inputs. This forced users to use workarounds like using apply in order to configure policies created in the same pulumi program.
This PR changes the policyArns attribute from a plain string array to an nested Input array (Input<Input<string>[]>) to allow users to pass the whole list as well as individual elements as eventual types.

Fixes #1197

Previously the policyArns attribute in RoleWithPolicyArgs only
accepted plain types as inputs. This forced users to use
workarounds like using `apply` in order to configure policies
created in the same pulumi program.

Fixes #1197
@flostadler flostadler requested a review from a team April 24, 2024 13:16
@flostadler flostadler self-assigned this Apr 24, 2024

/// <summary>
/// ARNs of the policies to attach to the created role.
/// </summary>
public List<string> PolicyArns
public InputList<string> PolicyArns
Copy link
Member

Choose a reason for hiding this comment

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

public sealed class InputList<T> : Input<ImmutableArray<T>>, IEnumerable, IAsyncEnumerable<Input<T>>

This is breaking I think.

Copy link
Member

Choose a reason for hiding this comment

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

I think dotnet has an implict conversion from List<T> to InputList<T>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try it out just to be sure. I was also under the impression, but better safe than sorry.

Copy link
Member

Choose a reason for hiding this comment

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

Oh that's true, I forgot about implicit conversions. That may be nice.

@@ -2129,7 +2129,7 @@ type RoleWithPolicyArgs struct {
// ARN of the policy that is used to set the permissions boundary for the role.
PermissionsBoundary pulumi.StringPtrInput `pulumi:"permissionsBoundary"`
// ARNs of the policies to attach to the created role.
PolicyArns []string `pulumi:"policyArns"`
PolicyArns pulumi.StringArrayInput `pulumi:"policyArns"`
Copy link
Member

Choose a reason for hiding this comment

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

This is certainly breaking.

* @return builder
*
*/
public Builder policyArns(List<String> policyArns) {
Copy link
Member

Choose a reason for hiding this comment

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

This is not breaking because a new overload is generated with the same sig.

@@ -310,7 +310,7 @@ export namespace awsx {
/**
* ARNs of the policies to attach to the created role.
*/
policyArns?: string[];
policyArns?: pulumi.Input<pulumi.Input<string>[]>;
Copy link
Member

Choose a reason for hiding this comment

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

I suspect TypeScript has enough magic this is not breaking.

Copy link
Contributor Author

@flostadler flostadler Apr 24, 2024

Choose a reason for hiding this comment

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

Yeah in typescript it is fine because Input is a type alias for T | Promise<T> | OutputInstance<T>

@flostadler
Copy link
Contributor Author

@t0yv0 You're absolutely correct about the breaking changes. I had started a thread about this on the original issue after I noticed it (sorry for not updating the PR yet!): #1197 (comment)

I'm thinking about adding a new parameter and deprecating the old one, do you have any other ideas to add this quality of life improvement without causing pain for other users?

@@ -69,7 +69,7 @@ export function defaultRoleWithPolicies(
): {
roleArn?: pulumi.Output<string>;
role?: aws.iam.Role;
policies?: aws.iam.RolePolicyAttachment[];
policies?: pulumi.Output<aws.iam.RolePolicyAttachment[]>;
Copy link
Member

Choose a reason for hiding this comment

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

I thought there was some magic way to do this change for the SDKs while still receiving un-wrapped values in the provider but I may be mistaken. If this works it's good.

I slightly worry about provisioning resources under apply inside the component resource, but I might need some platform team help to find references to how this works.

https://www.pulumi.com/docs/concepts/resources/components/#registering-component-outputs

Normally there is a call registerOutputs at the end of the constructor.

We don't seem to be calling it for ec2TaskDefinition:

https://github.com/pulumi/pulumi-awsx/blob/master/awsx/ecs/ec2TaskDefinition.ts#L32

If we're doing apply then children may register out-of-order that is after the component resource is done constructing and I vaguely recall this may cause bugs.

@t0yv0
Copy link
Member

t0yv0 commented Apr 24, 2024

Since examples/tests aren't changing looks like this may not be under test yet, would it be possible to add a quick end-to-end example using this?

@t0yv0
Copy link
Member

t0yv0 commented Apr 24, 2024

Re: slightly breaking changes like this, I need a reminder CC @mjeffryes on what our breaking change policy is here. It sounds like change is not breaking for TypeScript which may account for most of the user base. I agree with you that if we're strict on breaking changes then a new added property is a good alternative.

@flostadler
Copy link
Contributor Author

Since examples/tests aren't changing looks like this may not be under test yet, would it be possible to add a quick end-to-end example using this?

Yes for sure!

@flostadler
Copy link
Contributor Author

We're planning this for the next major version upgrade. Closing the PR for now, we can pick it up again once we're working on the next major version

@flostadler flostadler closed this May 8, 2024
@flostadler flostadler reopened this May 8, 2024
@flostadler flostadler marked this pull request as draft May 8, 2024 15:55
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.

policyArns in RoleWithPolicyArgs should be input
3 participants