Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pkg/provider/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ func manageRemoteState(ctx context.Context, backedURL string) error {
}

// pulumi config key : aws env credential
// Only region is set via Pulumi config; credentials (access key, secret key,
// session token) are resolved by the AWS SDK's default credential chain so
// that expired tokens stored in the Pulumi provider state never shadow
// fresh environment credentials on later operations (e.g. destroy).
var envCredentials = map[string]string{
awsConstants.CONFIG_AWS_REGION: "AWS_DEFAULT_REGION",
awsConstants.CONFIG_AWS_NATIVE_REGION: "AWS_DEFAULT_REGION",
awsConstants.CONFIG_AWS_ACCESS_KEY: "AWS_ACCESS_KEY_ID",
awsConstants.CONFIG_AWS_SECRET_KEY: "AWS_SECRET_ACCESS_KEY",
awsConstants.CONFIG_AWS_SESSION_TOKEN: "AWS_SESSION_TOKEN"}
awsConstants.CONFIG_AWS_NATIVE_REGION: "AWS_DEFAULT_REGION"}
Comment on lines +74 to +80

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Repo files matching aws.go/aws provider:"
fd -a 'aws\.go$' . | sed 's#^\./##' | head -100

echo
echo "Outline for pkg/provider/aws/aws.go if present:"
if [ -f pkg/provider/aws/aws.go ]; then
  ast-grep outline pkg/provider/aws/aws.go || true
  wc -l pkg/provider/aws/aws.go
  sed -n '1,180p' pkg/provider/aws/aws.go | cat -n
fi

echo
echo "Search for SetAWSCredentials / envCredentials / credential config references:"
rg -n "SetAWSCredentials|envCredentials|CONFIG_AWS_(ACCESS|SECRET|SESSION|REGION)|accessKey|secretKey|sessionToken|RemoveConfig|SetConfig|GetConfig|StackConfiguration" . --glob '!node_modules' --glob '!dist' --glob '!build' | head -200

Repository: redhat-developer/mapt

Length of output: 34564


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
p=Path('pkg/provider/aws/aws.go')
text=p.read_text() if p.exists() else ''
checks={
    'has_pkg': p.exists(),
    'line_count': len(text.splitlines()),
    'has_envCredentials': 'envCredentials' in text,
    'has_access_key_mapping': 'aws:accessKey' in text or 'CONFIG_ACCESS_KEY' in text,
    'has_secret_key_mapping': 'aws:secretKey' in text or 'CONFIG_SECRET_KEY' in text,
    'has_session_token_mapping': 'aws:sessionToken' in text or 'CONFIG_SESSION_TOKEN' in text,
    'has_SetAWSCredentials': 'SetAWSCredentials' in text,
    'has_remove_config': any(s in text for s in ['DeleteConfig', 'RemoveConfig', 'SetAWSCredentials']),
}
for k,v in checks.items():
    print(f'{k}: {v}')
if p.exists():
    idx=text.find('var envCredentials')
    if idx!=-1:
        print('--- envCredentials block ---')
        endidx=text.find('}', idx)+1
        print(text[idx:endidx])
PY

Repository: redhat-developer/mapt

Length of output: 552


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "constants:"
cat -n pkg/provider/aws/constants/constants.go | sed -n '1,40p'

echo
echo "manager stack implementation around credentials:"
rg -n "ProviderCredentials|SetAw|Config" pkg/manager pkg/manager/context -A5 -B5 --glob '!vendor' --glob '!dist' --glob '!build' | head -240

echo
echo "candidate manager stack file:"
fd -a 'stack\.go$|.*\.go$' pkg/manager | sed 's#^\./##' | while read -r f; do
  if rg -q "ProviderCredentials|SetConfig|SetAWSCredentials|DestroyStack" "$f"; then
    echo "--- $f"
    wc -l "$f"
    sed -n '1,220p' "$f" | cat -n
  fi
done

echo
echo "Pulumi SDK local_workspace config behavior (source-only):"
if [ -d vendor/github.com/pulumi/pulumi/sdk/v3/go/auto ]; then
  rg -n "func \\(l \\*LocalWorkspace\\) SetConfig|func SetConfig|RemoveConfig|Save" vendor/github.com/pulumi/pulumi/sdk/v3/go/auto/local_workspace.go -A8 -B4
else
  echo "vendor path missing"
fi

Repository: redhat-developer/mapt

Length of output: 24577


Clean up legacy AWS credential config in existing stacks.

SetAWSCredentials only writes keys in envCredentials via stack.SetConfig, so it does not remove existing persisted aws:accessKey, aws:secretKey, or aws:sessionToken values. Add a one-time migration that stack.RemoveConfigs those keys for stacks that already store them, otherwise existing stacks can still prefer stale Pulumi provider credentials over the SDK default chain.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/provider/aws/aws.go` around lines 74 - 80, Add a one-time migration in
SetAWSCredentials that removes persisted aws:accessKey, aws:secretKey, and
aws:sessionToken entries via stack.RemoveConfig before or alongside setting
envCredentials. Apply removal only when those legacy keys exist, while
preserving the existing region configuration and SDK default credential-chain
behavior.


var DefaultCredentials = GetClouProviderCredentials(nil)

Expand Down
3 changes: 0 additions & 3 deletions pkg/provider/aws/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package constants
const (
CONFIG_AWS_REGION string = "aws:region"
CONFIG_AWS_NATIVE_REGION string = "aws-native:region"
CONFIG_AWS_ACCESS_KEY string = "aws:accessKey"
CONFIG_AWS_SECRET_KEY string = "aws:secretKey"
CONFIG_AWS_SESSION_TOKEN string = "aws:token"
)

const (
Expand Down