function-upload-to-bucket/pulumi/main.ts: `aws:region` config value is never used
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 85/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- aws, typescript
- Domain
- documentation
Research direction
Start at docs/docs/src/examples/function-upload-to-bucket/pulumi/main.ts, line 8, where config.require("aws:region") is read into region and never used. Confirm the config object has no other use, then either delete the two lines or read the region from the aws namespace if the example should show it. Done when the sample has no unused config read and still deploys with aws:region set in the stack.
Written by the indexing model from the issue text.
Description
I tried this:
We read the Pulumi version of the function-upload-to-bucket docs example. Line 8 of main.ts reads the config value aws:region into region, but region is never used. The line has no effect on what is deployed, and because the key is looked up in the project namespace, pulumi up can stop with a missing-config error even when aws:region is set. This comes from reading the source; we did not deploy the example.
File: docs/docs/src/examples/function-upload-to-bucket/pulumi/main.ts (line 8)
Finding: Unused config value
const region = config.require("aws:region");
This happened:
What we found: region is not used anywhere else in the file: no resource, output or interpolation refers to it, and the config object is used only on this line. The AWS provider already takes its region from the aws:region stack config, so this line has no effect on what is deployed. Also, new pulumi.Config() scopes keys to the project, so this call looks up s3-lambda-pulumi:aws:region rather than aws:region.
Why it matters: Readers comparing tools on the docs page see an extra required config read that does nothing, which makes the Pulumi sample longer and suggests that the region must be wired by hand. Because the key is project-scoped, pulumi up can fail with a missing-config error even when aws:region is set.
I expected this:
The Pulumi sample reads only config values that it uses, and leaves the region to the AWS provider's own aws:region setting.
Suggested fix: Remove the two unused lines (the config object is used only here):
-const config = new pulumi.Config();
-const region = config.require("aws:region");
The AWS provider still reads aws:region from the stack config. If the sample should show the region explicitly, read it from the aws namespace instead, e.g. const region = aws.config.region; or new pulumi.Config("aws").require("region"), and then use it. This is not a breaking change.
Anything else?
We are researchers studying the quality of infrastructure-as-code templates, and this report refers to commit b65ae5c. The findings come from a static analyzer, the text was drafted with the help of an AI assistant, and we checked both by hand.
If this is intentional, please let us know or simply close the issue. If it helps, we are happy to open a pull request with the fix. Thank you!
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 217
- Avg merge
- 3h 45m
- Merged PRs (30d)
- 1
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from winglang/wing
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
🐛 bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
🐛 bug
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Cognito APIs aren't proxied correctlyMay be free again @deepakstwt claimed this 142 days ago, and no pull request is open. Open🐛 bug
Difficulty 3/5 1-2 days Newbie friendliness 48/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Invalid-link error for static location apps shows HTML-escaped sample URL (`/`)Possibly taken @cgmuniz claimed this today. Open🐛 bug
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
apps/stage-web bug env/os-linux pending triage scope/audio-output
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day