Skip to content

Changes for Deploying Dashboards for a subset of accounts#434

Open
Lavanya0513 wants to merge 5 commits into
aws-solutions-library-samples:mainfrom
Lavanya0513:main
Open

Changes for Deploying Dashboards for a subset of accounts#434
Lavanya0513 wants to merge 5 commits into
aws-solutions-library-samples:mainfrom
Lavanya0513:main

Conversation

@Lavanya0513

Copy link
Copy Markdown

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


# --- SOURCE PATH RESOURCES ---
# S3 Bucket for Athena query results
AthenaResultsBucket:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Customers already have Athena query results bucket delivered with main DataExport template in data collection account

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed the Athena and Glue components. will go with cid cmd

"billing_period"

FROM {source_db}.{source_table}
WHERE line_item_usage_account_id IN ('{account_filter}')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add a validation that account ids are matching account id format ^\d{12}$

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added

- athena:GetQueryExecution
- athena:GetQueryResults
- athena:StopQueryExecution
Resource: "*"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the Lambda role should be scoped to specific workgroups, databases, and tables rather than *

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Restricted to primary workgroup

- Sid: CrossAccountAccess
Effect: Allow
Principal:
AWS: !Sub 'arn:aws:iam::${DataCollectionAccountId}:root'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Granting :root means ANY principal in that account (any role, user, or service) can read, write, and delete objects. This should be scoped to a specific role ARN. The s3:DeleteObject permission is particularly concerning for a data collection bucket.


Resources:
# --- TARGET PATH RESOURCES ---
TargetDataBucket:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should enforce SSE-S3 or SSE-KMS at minimum

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Completed

print(f"Started query execution: {query_execution_id}")

# Wait for query completion
max_wait_time = 600 # 10 minutes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens to the query if it exceeds 10 min?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added a env variable. if Lambda times out, user can increase this value. Will add in instructions.


# Delete all existing files under data directory
prefix = f'cur2/{payer_account}/cid-cur2/cid-cur2/'
delete_all_files(target_bucket, prefix)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if Athena query fails afterwards? Will the bucket end up being empty?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes

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