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

Incorrect Java Code Example in Registry for aws.iam.GroupMembership resource #1340

Open
toriancrane opened this issue Apr 14, 2024 · 1 comment
Labels
area/codegen kind/bug Some behavior is incorrect or out of spec language/java

Comments

@toriancrane
Copy link

What happened?

I tried to deploy the Java example on this page and received the following error:

image

Example

Deploy the Java example on this page

Output of pulumi about

N/A

Additional context

The issue seems to be that we need to create a single output that is a List containing both outputs. Here is a version of this resource that works (courtesy of @cnunciato):

package myproject;

import com.pulumi.Pulumi;
import com.pulumi.aws.iam.User;
import com.pulumi.aws.iam.UserArgs;
import com.pulumi.aws.iam.Group;
import com.pulumi.aws.iam.GroupArgs;
import com.pulumi.aws.iam.GroupPolicy;
import com.pulumi.aws.iam.GroupPolicyArgs;
import com.pulumi.aws.iam.GroupMembership;
import com.pulumi.aws.iam.GroupMembershipArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import com.pulumi.core.Output;
import java.util.List;

public class App {
    public static void main(String[] args) {
        Pulumi.run(ctx -> {
            
            var jane = new User("jane", UserArgs.builder().build());
            var mary = new User("mary", UserArgs.builder().build());

            // Create a single output from the two other outputs.
            var userIds = Output.all(jane.id(), mary.id()).applyValue(ids -> List.of(ids.get(0), ids.get(1)));
            
            // Define a group and assign a policy for it.
            var devs = new Group("devs", GroupArgs.builder()
                .path("/users/")
                .build());
            
            new GroupPolicy("my_developer_policy", GroupPolicyArgs.builder()
                .group(devs.name())
                .policy(serializeJson(
                    jsonObject(
                        jsonProperty("Version", "2012-10-17"),
                        jsonProperty("Statement", jsonArray(jsonObject(
                            jsonProperty("Action", jsonArray("ec2:Describe*")),
                            jsonProperty("Effect", "Allow"),
                            jsonProperty("Resource", "*")
                        )))
                    )))
                .build());
    
            new GroupMembership("dev-team", GroupMembershipArgs.builder()
                .group(devs.id())
                .users(userIds)
                .build());
        });
    }
}

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@toriancrane toriancrane added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Apr 14, 2024
@justinvp justinvp transferred this issue from pulumi/pulumi Apr 15, 2024
@justinvp justinvp added area/codegen language/java and removed needs-triage Needs attention from the triage team labels Apr 15, 2024
@t0yv0
Copy link
Member

t0yv0 commented Apr 15, 2024

Yeah this landed in java bypassing pulumi-aws but I think it goes through the conversion pipeline, LMK if it's helpful to pull out the PCL/HCL phases here for this example. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen kind/bug Some behavior is incorrect or out of spec language/java
Projects
None yet
Development

No branches or pull requests

3 participants