feat(cli): Add hotswap support for QuickSight resources#1055
feat(cli): Add hotswap support for QuickSight resources#1055
Conversation
Head branch was pushed to by a user without write access
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1055 +/- ##
==========================================
- Coverage 87.79% 87.78% -0.01%
==========================================
Files 73 73
Lines 10168 10168
Branches 1343 1343
==========================================
- Hits 8927 8926 -1
- Misses 1217 1218 +1
Partials 24 24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| Name: evaluatedProps.Name ?? props.Name, | ||
| PhysicalTableMap: evaluatedProps.PhysicalTableMap, | ||
| LogicalTableMap: evaluatedProps.LogicalTableMap, | ||
| ImportMode: props.ImportMode, |
There was a problem hiding this comment.
ImportMode here is passed as raw props.ImportMode without evaluation, unlike other properties that use evaluatedProps
What is the reason this is raw CFN and not being evaluated like the other properties?
There was a problem hiding this comment.
Good catch. ImportMode should be evaluated through evaluateCfnExpression like other properties, otherwise CFN intrinsic functions (e.g. { Ref: 'SomeParam' }) would be passed as raw objects to the QuickSight API instead of being resolved.
Fixed in the latest commit - ImportMode is now evaluated. I also fixed the Name fallback path (evaluatedProps.Name ?? props.Name) which had the same issue: when Name hadn't changed but contained an intrinsic function, the raw CFN object was passed through instead of the resolved value. Added tests for both cases.
|
|
||
| const QUICKSIGHT_RESOURCE_TYPES: Record<string, { hotswappableProps: string[]; service: string }> = { | ||
| 'AWS::QuickSight::DataSet': { hotswappableProps: ['PhysicalTableMap', 'LogicalTableMap', 'Name'], service: 'quicksight-dataset' }, | ||
| 'AWS::QuickSight::DataSource': { hotswappableProps: ['DataSourceParameters', 'Name', 'Credentials'], service: 'quicksight-datasource' }, |
There was a problem hiding this comment.
Is it safe to allow hotswapping credentials? I'm unsure if there is any extra consideration here but want to clarify
There was a problem hiding this comment.
Good question - I've removed Credentials from the hotswappable properties list. Several reasons:
-
Write-only property in the CFN schema: The CloudFormation resource schema for
AWS::QuickSight::DataSourceexplicitly listsCredentialsunderwriteOnlyProperties. This is the CloudFormation team's classification that this property contains sensitive data that cannot be read back viaDescribeDataSource. -
Sensitive data:
Credentialscan contain plaintext usernames/passwords (CredentialPair), private keys (KeyPairCredentials), or Secrets Manager ARNs (SecretArn). Bypassing CloudFormation's change set review for credential changes removes a safety checkpoint that's especially important for secrets. -
Hotswap is for fast dev iteration: You'd typically iterate rapidly on dashboard definitions, dataset schemas, or data source connection parameters - not on credentials. Credential changes are infrequent and warrant the full CloudFormation deployment path for auditability and review.
No other hotswap handler in the codebase hotswaps dedicated credential/secret properties, so this is consistent with the existing pattern.
Added a test confirming that Credentials changes on DataSource are correctly rejected by the hotswap detector.
There was a problem hiding this comment.
I think there could be tests for
- CFN intrinsic functions existing on the properties
- Both hotswappable and non-hotswappable properties changing together
There was a problem hiding this comment.
Added four new tests covering both areas:
CFN intrinsic functions on properties:
Fn::JoinwithRefin the DashboardNameproperty — verifies it resolves correctly (e.g."dashboard-my-bucket"instead of the raw{"Fn::Join": ...}object){ Ref: 'Param' }in the DataSetImportMode— verifies the required-but-non-hotswappable property is also properly evaluated (relates to comment chore(deps): upgrade dependencies #1)
Mixed hotswappable + non-hotswappable changes:
3. PhysicalTableMap (hotswappable) + Permissions (non-hotswappable) changing together on a DataSet — verifies FALL_BACK mode returns undefined with no SDK call, and HOTSWAP_ONLY mode hotswaps only the hotswappable properties
4. Credentials-only change on DataSource — verifies it's rejected in both modes (relates to comment #2)
|
All review feedback has been addressed:
All CI checks are passing (including all integration test shards). Could I get a re-review when you have a chance? Thanks! |
fe368f4 to
2cff3c3
Compare
Resolves @smithy/types version conflicts with test infrastructure. Now properly builds without TypeScript compilation errors.
ESLint auto-fix alphabetizes imports as required by project style rules. This matches CI expectations and prevents build-time file changes.
- Evaluate ImportMode through evaluateCfnExpression instead of passing raw CFN, consistent with how other properties are handled - Evaluate Name fallback through evaluateCfnExpression so CFN intrinsic functions (Ref, Fn::Join, etc.) resolve correctly even when Name itself hasn't changed - Remove Credentials from DataSource hotswappable properties — credential changes should go through CloudFormation for proper review - Add tests for CFN intrinsic functions on hotswappable properties - Add tests for CFN intrinsic functions in ImportMode (DataSet) - Add test for mixed hotswappable and non-hotswappable property changes - Add test verifying Credentials changes are not hotswapped
82a72c6 to
6df13e8
Compare
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
This PR adds hotswap deployment support for Amazon QuickSight resources, enabling faster iterative development when working with QuickSight dashboards, analyses, datasets, data sources, and templates.
Motivation
QuickSight resources often require frequent updates during development, particularly when iterating on dashboard definitions, data mappings, and visualizations. Full CloudFormation deployments for these changes can be slow. Hotswap allows developers to bypass CloudFormation and update resources directly
via the AWS API, significantly reducing deployment time during development.
Changes
New QuickSight Hotswap Handler (lib/api/hotswap/quicksight.ts)
Adds hotswap support for five QuickSight resource types:
The implementation:
SDK Integration (lib/api/aws-auth/sdk.ts)
Adds IQuickSightClient interface and quickSight() method to the SDK class with support for:
Hotswap Registration (lib/api/hotswap/hotswap-deployments.ts)
Registers the QuickSight detector for all five resource types in the RESOURCE_DETECTORS map.
Test Infrastructure (test/_helpers/mock-sdk.ts)
Adds mockQuickSightClient for testing QuickSight hotswap operations.
Testing
Added comprehensive test suite (test/api/hotswap/quicksight-hotswap-deployments.test.ts) covering:
Usage Example
bash
Deploy with hotswap enabled - QuickSight changes will be applied directly
cdk deploy --hotswap
Or hotswap-only mode (skip non-hotswappable changes)
cdk deploy --hotswap-fallback
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license