Skip to content

Get Started/AWS tutorial: Go component snippet passes wrong resource to RegisterResourceOutputs; Java skeleton has compile errors; Java resource names inconsistent with other languages #21020

Description

@workprentice

Summary

While auditing the AWS Get Started tutorial (content/docs/iac/get-started/aws/) I found three concrete code defects that would trip up a reader following along in Go or Java.

1. Go: RegisterResourceOutputs called on the wrong resource

In create-component.md, the final componentized NewAwsS3Website function calls:

ctx.RegisterResourceOutputs(website, pulumi.Map{"url": self.Url}) // Signal component completion.

website is the child s3.BucketWebsiteConfiguration resource, not the component (self). Every other language variant in the same section correctly registers outputs against the component instance (TypeScript's this.registerOutputs(...), Python's self.register_outputs(...), C#'s this.RegisterOutputs(...), Java's this.registerOutputs(...)). Passing a child resource here associates the outputs metadata with the wrong resource. It should be:

ctx.RegisterResourceOutputs(self, pulumi.Map{"url": self.Url}) // Signal component completion.

2. Java: skeleton component snippet does not compile

Earlier in the same file, under "Define a new component," the skeleton Java snippet has:

public class AwsS3WebsiteArgs {
    public String[] files;
    ...
}

public class AwsS3Website extends ComponentResource {
    public Output<String> url;

    public AwsS3Website(String name, AwsS3WebsiteArgs args, ComponentResourceOptions opts) {
        super("quickstart:index:AwsS3Website", name, args, opts);
        ...
        this.registerOutputs(Map.of());
    }
}

This does not compile: AwsS3WebsiteArgs does not extend ResourceArgs, yet it's passed to the ComponentResource constructor overload that requires a ResourceArgs-typed third argument; Output<String> is used without importing com.pulumi.core.Output; and Map.of() is used without importing java.util.Map. The corrected snippet later in the same file (under "Refactor your code into the component") does have all three, confirming this is a simple omission in the skeleton rather than an intentional simplification.

3. Java: resource logical names inconsistent with every other language

In the componentized Java example (also in create-component.md), two resources use camelCase logical names:

var ownershipControls = new BucketOwnershipControls("ownershipControls", ...)
var publicAccessBlock = new BucketPublicAccessBlock("publicAccessBlock", ...)

Every other language variant (TypeScript, Python, Go, C#, YAML/HCL) uses kebab-case ("ownership-controls", "public-access-block") for the identical resources, and the shared pulumi up output sample shown for all languages in this section shows the kebab-case names. A Java reader who copies the shown code will see different resource names in their own CLI output than what the tutorial's shared sample shows.

Where

All three are in content/docs/iac/get-started/aws/create-component.md.

Suggested fix

  • Change ctx.RegisterResourceOutputs(website, ...) to ctx.RegisterResourceOutputs(self, ...).
  • Add extends ResourceArgs to the skeleton AwsS3WebsiteArgs class and add the missing com.pulumi.core.Output and java.util.Map imports to that skeleton snippet.
  • Rename the two Java resource logical names to "ownership-controls" and "public-access-block" to match the other language variants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/docs-contentIssues relating to content under pulumi.com/docsarea/tutorials-contentIssues relating to content tutorials showing how to write Pulumi IaC programskind/bugresolution/fixedThis issue was fixed

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions