Skip to content

fix: align shield_advanced configuration role trust policy with sibli… - #347

Merged
justin-kontny merged 2 commits into
aws-samples:mainfrom
ericrose:fix/shield-advanced-configuration-role-trust-policy
Jul 29, 2026
Merged

fix: align shield_advanced configuration role trust policy with sibli…#347
justin-kontny merged 2 commits into
aws-samples:mainfrom
ericrose:fix/shield-advanced-configuration-role-trust-policy

Conversation

@ericrose

@ericrose ericrose commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Wire the existing pShieldOrgLambdaRoleName parameter into rConfigurationRole's AssumeRolePolicyDocument via a Condition/StringEquals/aws:PrincipalArn block, so the cross-account role scopes to the solution's own Lambda execution role. The Principal element continues to name the account root, which is required because the role does not exist when the trust policy is authored.

The parameter was declared but never referenced, so this also removes a dead parameter. This brings the template in line with the pattern already used by the sibling configuration roles across the repo, including guardduty_org, macie_org, securityhub_org, detective_org, inspector_org, config_org, ami_bakery_org, firewall_manager_org, ec2_default_ebs_encryption, s3_block_account_public_access, and account_alternate_contacts.

No functional change to the solution: both sts:AssumeRole call sites run in the management account under pShieldOrgLambdaRoleName, and the parameter default is identical in both templates. Verified with cfn-lint (clean) and checkov (8 passed, 0 failed).

Fixes #


By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

Apache 2.0 License

The pylic workflow fails on main with:

  Safe licenses listed which are not used by any installed package:
    BSD-3-Clause

This is not a license violation. No installed package carries a disallowed
license; pylic objects that BSD-3-Clause is listed in [tool.pylic]
safe_licenses while no installed package currently uses it.

Two factors combine to trigger it. The workflow runs a bare
`pip install pylic` with no version constraint, so it bypasses the
pylic = "^3.4.0" pin in pyproject.toml and resolves pylic 5.x, which turned
unused safe_licenses entries into a hard failure. And the job installs
`--only main`, so the small dependency set leaves BSD-3-Clause unmatched.

Pass --allow-extra-safe-licenses, the flag pylic 5 provides for exactly this
case. The entry stays in the allowlist and is reported as informational
instead of fatal, so the check keeps failing on genuinely unsafe licenses
while no longer failing on an unused allowlist entry.

Verified locally against a venv reproducing the CI environment (main-only
dependencies, pylic 5.0.1): reproduces the failure (exit 1) before the change
and passes with "All licenses ok" (exit 0) after, with BSD-3-Clause retained.

Note that pinning to pylic <4 was considered and rejected: pylic 3.6.1 fails
more broadly in this environment, additionally reporting MIT as unused and
flagging six packages (including setuptools and urllib3) as unsafe.
@ericrose
ericrose requested a review from justin-kontny July 29, 2026 16:34
…ng solutions

Wire the existing pShieldOrgLambdaRoleName parameter into rConfigurationRole's
AssumeRolePolicyDocument via a Condition/StringEquals/aws:PrincipalArn block, so
the cross-account role scopes to the solution's own Lambda execution role. The
Principal element continues to name the account root, which is required because
the role does not exist when the trust policy is authored.

The parameter was declared but never referenced, so this also removes a dead
parameter. This brings the template in line with the pattern already used by the
sibling configuration roles across the repo, including guardduty_org, macie_org,
securityhub_org, detective_org, inspector_org, config_org, ami_bakery_org,
firewall_manager_org, ec2_default_ebs_encryption, s3_block_account_public_access,
and account_alternate_contacts.

No functional change to the solution: both sts:AssumeRole call sites run in the
management account under pShieldOrgLambdaRoleName, and the parameter default is
identical in both templates. Verified with cfn-lint (clean) and checkov
(8 passed, 0 failed).
@ericrose
ericrose force-pushed the fix/shield-advanced-configuration-role-trust-policy branch from be54c07 to 83e28f0 Compare July 29, 2026 16:46
@justin-kontny
justin-kontny merged commit f22488d into aws-samples:main Jul 29, 2026
6 checks passed
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.

2 participants