Skip to content

fix(awsutil): let SkipRegionalForGlobalService honor explicit aws-global clients - #984

Open
chadwpetersen wants to merge 5 commits into
ekristen:mainfrom
instruqt:instruqt/cfn-create-role-fix
Open

chadwpetersen wants to merge 5 commits into
ekristen:mainfrom
instruqt:instruqt/cfn-create-role-fix

Conversation

@chadwpetersen

@chadwpetersen chadwpetersen commented Jun 23, 2026

Copy link
Copy Markdown

CreateRoleToDeleteStack (CloudFormationStack) and CreateRoleToDelete (SSMQuickSetupConfigurationManager) both build an IAM client from the regional opts.Config and call iam.CreateRole to recreate a missing role. The SkipRegionalForGlobalService middleware that NewConfig attaches to every regional config refuses these calls:

operation error IAM: CreateRole, service 'IAM' is global, but the session is not

Move the workaround into the middleware itself: clients explicitly built with Region = "aws-global" pass through. Accidental misuse (no region override) is still blocked with the original error.

Resources that legitimately need IAM from a regional scanner can now just set o.Region = "aws-global" on the client.

Pin the IAM client built in CloudFormationStackLister to aws-global and
strip the SkipRegionalForGlobalService middleware that NewConfig attaches
to every regional config. Without this, the CreateRoleToDeleteStack
recovery path is refused by ekristen's own middleware with
"service 'IAM' is global, but the session is not", leaving stacks with
a stale RoleARN stuck in DELETE_FAILED forever.
…bal clients

Move the workaround for global-service calls from a regional context into
the middleware itself: clients explicitly built with Region="aws-global"
pass through. Accidental misuse (no region override) is still blocked
with the original error message.

This collapses the bespoke workaround in cloudformation-stack.go and
covers ssmquicksetup-configuration-manager.go, which had the identical
bug for its CreateRoleToDelete recovery path.

Resources that legitimately need IAM from a regional scanner now just
set o.Region = "aws-global" on the client — no APIOptions surgery.
@chadwpetersen chadwpetersen changed the title fix(cloudformation-stack): allow CreateRole on regional configs fix(awsutil): let SkipRegionalForGlobalService honor explicit aws-global clients Jun 25, 2026
@chadwpetersen chadwpetersen reopened this Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant