Repository navigation
feat(cid-cmd): Add athena-profile for cross-account Athena - #1600
Open
mightymietz wants to merge 1 commit into
Open
mightymietz wants to merge 1 commit into
mightymietz wants to merge 1 commit into
Conversation
Allow QuickSight in one account (hub) and Athena, Glue and S3 in another (spoke) via --athena-profile, a named AWS profile for a role in the data account. QuickSight, IAM, CFN and Organizations keep the base session. deploy/update require a DataSource with ConsumerAccountRoleArn in the data account and bind its workgroup before any Athena call. Creating datasources, crawlers and CUR tables is refused in this mode, as is Lambda/CloudFormation. Connection parameters are not stored in cid_parameters.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1599
Summary
Adds an optional
--athena-profile <name>so that cid-cmd can deploy dashboards in a hub-and-spoke setup: Quick runs in one account, while the CUR, the Glue database and the Athena workgroup stay in another account (for example the Data Collection account). It builds on Quick's cross-account Athena data sources (RoleArn→ConsumerAccountRoleArn).--profile/ default credentials--athena-profileWithout
--athena-profile, behaviour is unchanged, except one new safeguard:deploy/update/deletestop if the DataSource they use queries another account.Changes
cid/common.pyaws_login()opens a second session from--athena-profile(same Region, partition checked against the caller identity). Theathena,glueands3helpers usedata_account, which falls back tobase._deploy()preflight in cross-account mode: requires--quicksight-datasource-id, validates the DataSource (Athena,CREATION_SUCCESSFUL/UPDATE_SUCCESSFUL, workgroup set,ConsumerAccountRoleArnin the data account and partition) and binds its workgroup before any Athena call.create_datasource(), crawler creation (checked before any table change; existing crawlers are left alone) andcreate_cur_table().teardownkeeps aCID-CMD-AthenaDataSource that usesConsumerAccountRoleArn, and the role it references.{account_id}in view parameter defaults and the Glue catalog id now use the data account (no change in single-account mode).CONNECTION_PARAMETERS, incl.athena-profile) are neither stored in nor loaded fromcid_parameters.cid/cli.py: help text for--athena-profileondeploy,update,delete,map,export,create-cur-proxyandteardown;--quicksight-datasource-iddescribed as an ID, not an ARN.docs/cid-cmd.md,CID-CMD.md: new "Cross-account (hub-and-spoke)" section with the three roles (DataSource role, consumer role, deployment role) incl. trust and permission policies, acreate-data-sourceexample, a command matrix, the checks and the limitations.cid/test/python/test_cross_account.py: 37 new unit tests.Out of scope
Listed as follow-ups in #1599:
delete,teardownandexportPre-existing behaviour that this PR does not change: unknown
--optionsare accepted silently, andCidCriticalexits with status 0.Testing
pytest cid/test/python/: 363 passed (37 new)eu-central-1:deployandupdate --recursiveofcudos-v5succeed; all views are created in the data account, none in the Quick account--athena-workgroupstops before touching Athena--athena-profilestops before touching Athenatest_without_profile_everything_uses_base_accountSecurity
The change opens a second AWS session. Credentials are handled entirely by boto3 through the named profile; cid-cmd neither reads, logs nor stores them. Happy to go through an AppSec review if needed.