Conversation
📝 WalkthroughWalkthroughSetUp builds and passes CloudFormation parameters to a parameterized upsertStackAndWait; CloudFormation outputs include a CI role ARN and TaskDef ARN key rename; OIDC JWK struct exposes RSA fields and DER cert bytes and thumbprint extraction now prefers x5t; minor test/comment adjustments. Changes
Sequence Diagram(s)sequenceDiagram
participant SetUp as SetUp
participant Upserter as upsertStackAndWait
participant CFN as CloudFormation API
participant Mapper as fillWithOutputs
SetUp->>Upserter: Build parameters (VPC, RetainBucket, flags, creds)\nCall upsertStackAndWait(template, parameters...)
Upserter->>CFN: UpdateStack (with parameters)
CFN-->>Upserter: APIError (stack not found)
alt Stack Missing
Upserter->>CFN: CreateStack (with parameters)
CFN-->>Upserter: CreateStack success
else Stack Exists
CFN-->>Upserter: UpdateStack success
end
Upserter->>CFN: DescribeStacks (wait)
CFN-->>Upserter: Stack outputs
Upserter->>Mapper: Provide outputs
Mapper-->>Upserter: Populated OutputsTaskDefARN, OutputsCIRoleARN
Upserter-->>SetUp: Return success / populated config
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/pkg/clouds/aws/ecs/cfn/setup.go (1)
184-200: Allow Docker Hub credentials to be cleared after being set.The current implementation uses
os.Getenv, which treats unset and explicitly empty environment variables identically. This prevents clearing credentials because omitted parameters fall back toUsePreviousValuein CloudFormation updates. Switch toos.LookupEnvto distinguish between unset (preserve previous) and explicitly empty (clear parameter):🔧 Proposed fix
- if dockerHubUsername := os.Getenv("DOCKERHUB_USERNAME"); dockerHubUsername != "" { + if dockerHubUsername, ok := os.LookupEnv("DOCKERHUB_USERNAME"); ok { parameters = append(parameters, cfnTypes.Parameter{ ParameterKey: ptr.String(ParamsDockerHubUsername), ParameterValue: ptr.String(dockerHubUsername), }) } - if dockerHubToken := os.Getenv("DOCKERHUB_ACCESS_TOKEN"); dockerHubToken != "" { + if dockerHubToken, ok := os.LookupEnv("DOCKERHUB_ACCESS_TOKEN"); ok { parameters = append(parameters, cfnTypes.Parameter{ ParameterKey: ptr.String(ParamsDockerHubAccessToken), ParameterValue: ptr.String(dockerHubToken), }) }
🤖 Fix all issues with AI agents
In `@src/pkg/clouds/aws/ecs/cfn/oidc.go`:
- Line 19: The X5c field currently typed as [][]byte will fail to unmarshal JWK
x5c entries (they are JSON strings containing standard base64), so change the
X5c field on the OIDC JWK struct to []string (or []json.RawMessage) and when you
need the DER bytes decode them with base64.StdEncoding.DecodeString (e.g. in the
codepath that inspects key.X5c). Also add the encoding/base64 import and handle
decode errors where you reference X5c so usages of X5c (the commented else-if
branch or any function that reads key.X5c) work correctly.
* Retry setting the policies on service account up to 3 times (#1851) * Retry setting the policies on service account up to 3 times * Address code rabbit comment * continue to the correct outter check policy loop --------- Co-authored-by: Edward J <edw@defang.io> * fix(upgrade): avoid running slow "brew config" unless necessary (#1859) * fix: use shortened links for docs (#1858) * Stacks Cleanup (#1855) * avoid reading from global stacks when session stacks is available * require stack during deployment in interactive mode * Lio/stacks (#1860) * avoid reading from global stacks when session stacks is available * require stack during deployment in interactive mode * fix: panic when DEFANG_PROVIDER is not set would cause GetRegionVarName("") * fix: handle empty stack file * fix: abort stack loading on ctrl-c --------- Co-authored-by: Jordan Stephens <jordan@stephens.io> * chore: fix estimate unit test * Standardize the file and dir mode for context test (#1852) * Standardize the file and dir mode for context test * Update src/pkg/cli/compose/context_test.go * Remove unused import term --------- Co-authored-by: Edward J <edw@defang.io> Co-authored-by: Lio李歐 <lionello@users.noreply.github.com> * allow --provider to override default stack (#1862) * allow fallback stack when !RequireStack * s/RequireStack/DisallowFallbackStack/ * only log fallback when actually using fallback * s/RequireStack/DisallowFallbackStack/ * prefer --provider if available * coderabbbit feedback * refactor: improve error handling and warnings in whoami command --------- Co-authored-by: Lionello Lunesu <lio+git@lunesu.com> Co-authored-by: Hao Jiang <edwardrf@gmail.com> * fix: don't overwrite known state with NOT_SPECIFIED * fix(aws): add CloudFormation metadata --------- Co-authored-by: Hao Jiang <edwardrf@gmail.com> Co-authored-by: Edward J <edw@defang.io> Co-authored-by: Jordan Stephens <jordan@stephens.io>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/pkg/clouds/aws/ecs/cfn/template.go`:
- Around line 709-717: TemplateRevision needs to be incremented to reflect the
template changes (new Outputs and metadata) so OutputsTemplateVersion is not
stale; locate the constant or variable named TemplateRevision in this file and
bump its numeric value (e.g., from 3 to 4), then ensure any related exported
value OutputsTemplateVersion is derived from that constant so downstream
consumers pick up the new revision; verify no other places rely on the old
number and update tests or comments referencing the previous revision.
Description
CIRoleARN CloudFormation output was not an ARN.
defang cloudformationto create the template YAML to put in our public S3 bucket (MVP repo, ecs folder)Checklist
Summary by CodeRabbit
Tests
Refactor
Chore
✏️ Tip: You can customize this high-level summary in your review settings.