-
Notifications
You must be signed in to change notification settings - Fork 62
[SVLS-7027] Add Step Functions Flare Command #1701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ryanstrat
wants to merge
18
commits into
master
Choose a base branch
from
ryan.strat/step-functions-flare
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,940
−2
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b1a53c0
feat(stepfunctions): Add Step Functions flare command with tests (TDD…
ryanstrat 6925721
feat(stepfunctions): add flare command for diagnostic data collection
ryanstrat 287fbc0
feat(stepfunctions): improve flare command output and insights genera…
ryanstrat 59fb023
Add docblocks and log subscription filters to insights
ryanstrat 0f99107
docs: Add Step Functions flare command to main README
ryanstrat 5162895
feat(stepfunctions): improve flare command with enhanced cleanup and …
ryanstrat 8527582
fix(stepfunctions): Fix output text alignment
ryanstrat bda914b
Address PR review feedback
ryanstrat 4f67bbf
Address PR review feedback
ryanstrat c7aa264
Use tabs after emoji for consistent alignment
ryanstrat 0485fdd
Improve emoji alignment in output messages
ryanstrat 76fa2b2
Enhance insights file with configuration analysis
ryanstrat 3ccce9d
Apply code formatting
ryanstrat b7a0213
Fix CloudWatch logs emoji alignment
ryanstrat 3b80775
Fix CloudWatch logs collection
ryanstrat b6ce512
Address PR review feedback
ryanstrat dd0975b
Improve error handling for missing log groups
ryanstrat 8dbec68
Improve error handling for missing log groups
ryanstrat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
227 changes: 227 additions & 0 deletions
227
src/commands/stepfunctions/__tests__/fixtures/stepfunctions-flare.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,227 @@ | ||
| import {SubscriptionFilter, OutputLogEvent} from '@aws-sdk/client-cloudwatch-logs' | ||
| import {DescribeStateMachineCommandOutput, ExecutionListItem, HistoryEvent, Tag} from '@aws-sdk/client-sfn' | ||
|
|
||
| export const stateMachineConfigFixture = ( | ||
| props: Partial<DescribeStateMachineCommandOutput> = {} | ||
| ): DescribeStateMachineCommandOutput => { | ||
| const defaults: DescribeStateMachineCommandOutput = { | ||
| $metadata: {}, | ||
| stateMachineArn: 'arn:aws:states:us-east-1:123456789012:stateMachine:MyWorkflow', | ||
| name: 'MyWorkflow', | ||
| status: 'ACTIVE', | ||
| definition: JSON.stringify({ | ||
| StartAt: 'HelloWorld', | ||
| States: { | ||
| HelloWorld: { | ||
| Type: 'Pass', | ||
| Result: 'Hello World!', | ||
| End: true, | ||
| }, | ||
| }, | ||
| }), | ||
| roleArn: 'arn:aws:iam::123456789012:role/MyRole', | ||
| type: 'STANDARD', | ||
| creationDate: new Date('2024-01-01'), | ||
| loggingConfiguration: { | ||
| level: 'ALL', | ||
| includeExecutionData: true, | ||
| destinations: [ | ||
| { | ||
| cloudWatchLogsLogGroup: { | ||
| logGroupArn: 'arn:aws:logs:us-east-1:123456789012:log-group:/aws/vendedlogs/states/MyWorkflow-Logs', | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| } | ||
|
|
||
| return {...defaults, ...props} | ||
| } | ||
|
|
||
| export const sensitiveStateMachineConfigFixture = (): DescribeStateMachineCommandOutput => { | ||
| return stateMachineConfigFixture({ | ||
| definition: JSON.stringify({ | ||
| StartAt: 'ProcessPayment', | ||
| States: { | ||
| ProcessPayment: { | ||
| Type: 'Task', | ||
| Resource: 'arn:aws:lambda:us-east-1:123456789012:function:ProcessPayment', | ||
| Parameters: { | ||
| 'ApiKey.$': '$.credentials.apiKey', | ||
| SecretToken: 'secret-12345-token', | ||
| DatabasePassword: 'super-secret-password', | ||
| }, | ||
| End: true, | ||
| }, | ||
| }, | ||
| }), | ||
| description: 'Payment processing workflow with sensitive data', | ||
| }) | ||
| } | ||
|
|
||
| export const executionsFixture = (): ExecutionListItem[] => { | ||
| return [ | ||
| { | ||
| executionArn: 'arn:aws:states:us-east-1:123456789012:execution:MyWorkflow:execution1', | ||
| stateMachineArn: 'arn:aws:states:us-east-1:123456789012:stateMachine:MyWorkflow', | ||
| name: 'execution1', | ||
| status: 'SUCCEEDED', | ||
| startDate: new Date('2024-01-01T10:00:00Z'), | ||
| stopDate: new Date('2024-01-01T10:01:00Z'), | ||
| }, | ||
| { | ||
| executionArn: 'arn:aws:states:us-east-1:123456789012:execution:MyWorkflow:execution2', | ||
| stateMachineArn: 'arn:aws:states:us-east-1:123456789012:stateMachine:MyWorkflow', | ||
| name: 'execution2', | ||
| status: 'FAILED', | ||
| startDate: new Date('2024-01-01T09:00:00Z'), | ||
| stopDate: new Date('2024-01-01T09:01:00Z'), | ||
| }, | ||
| ] | ||
| } | ||
|
|
||
| interface SensitiveExecution { | ||
| executionArn: string | ||
| stateMachineArn: string | ||
| name: string | ||
| status: string | ||
| startDate: Date | ||
| stopDate: Date | ||
| input: string | ||
| output: string | ||
| } | ||
|
|
||
| export const sensitiveExecutionFixture = (): SensitiveExecution => { | ||
| return { | ||
| executionArn: 'arn:aws:states:us-east-1:123456789012:execution:MyWorkflow:execution1', | ||
| stateMachineArn: 'arn:aws:states:us-east-1:123456789012:stateMachine:MyWorkflow', | ||
| name: 'execution1', | ||
| status: 'SUCCEEDED', | ||
| startDate: new Date('2024-01-01T10:00:00Z'), | ||
| stopDate: new Date('2024-01-01T10:01:00Z'), | ||
| input: '{"creditCard": "4111-1111-1111-1111", "cvv": "123", "amount": 100}', | ||
| output: '{"transactionId": "secret-transaction-id", "authToken": "Bearer secret-token"}', | ||
| } | ||
| } | ||
|
|
||
| export const executionHistoryFixture = (): HistoryEvent[] => { | ||
| return [ | ||
| { | ||
| timestamp: new Date('2024-01-01T10:00:00Z'), | ||
| type: 'ExecutionStarted', | ||
| id: 1, | ||
| previousEventId: 0, | ||
| executionStartedEventDetails: { | ||
| input: '{"orderId": "12345"}', | ||
| roleArn: 'arn:aws:iam::123456789012:role/MyRole', | ||
| }, | ||
| }, | ||
| { | ||
| timestamp: new Date('2024-01-01T10:00:01Z'), | ||
| type: 'TaskStateEntered', | ||
| id: 2, | ||
| previousEventId: 1, | ||
| stateEnteredEventDetails: { | ||
| name: 'ProcessPayment', | ||
| input: '{"orderId": "12345", "amount": 100}', | ||
| }, | ||
| }, | ||
| { | ||
| timestamp: new Date('2024-01-01T10:00:59Z'), | ||
| type: 'TaskStateExited', | ||
| id: 3, | ||
| previousEventId: 2, | ||
| stateExitedEventDetails: { | ||
| name: 'ProcessPayment', | ||
| output: '{"success": true, "transactionId": "tx-12345"}', | ||
| }, | ||
| }, | ||
| { | ||
| timestamp: new Date('2024-01-01T10:01:00Z'), | ||
| type: 'ExecutionSucceeded', | ||
| id: 4, | ||
| previousEventId: 3, | ||
| executionSucceededEventDetails: { | ||
| output: '{"result": "completed"}', | ||
| }, | ||
| }, | ||
| ] | ||
| } | ||
|
|
||
| export const stepFunctionTagsFixture = (): Tag[] => { | ||
| return [ | ||
| {key: 'Environment', value: 'test'}, | ||
| {key: 'Service', value: 'payment-processor'}, | ||
| {key: 'Team', value: 'platform'}, | ||
| ] | ||
| } | ||
|
|
||
| export const logSubscriptionFiltersFixture = (): SubscriptionFilter[] => { | ||
| return [ | ||
| { | ||
| filterName: 'datadog-forwarder', | ||
| destinationArn: 'arn:aws:lambda:us-east-1:123456789012:function:DatadogForwarder', | ||
| filterPattern: '', | ||
| logGroupName: '/aws/vendedlogs/states/MyWorkflow-Logs', | ||
| }, | ||
| ] | ||
| } | ||
|
|
||
| export const cloudWatchLogsFixture = (): OutputLogEvent[] => { | ||
| return [ | ||
| { | ||
| timestamp: 1704106800000, | ||
| message: 'Execution started', | ||
| ingestionTime: 1704106801000, | ||
| }, | ||
| { | ||
| timestamp: 1704106801000, | ||
| message: 'Processing payment for order 12345', | ||
| ingestionTime: 1704106802000, | ||
| }, | ||
| { | ||
| timestamp: 1704106859000, | ||
| message: 'Payment processed successfully', | ||
| ingestionTime: 1704106860000, | ||
| }, | ||
| { | ||
| timestamp: 1704106860000, | ||
| message: 'Execution completed', | ||
| ingestionTime: 1704106861000, | ||
| }, | ||
| ] | ||
| } | ||
|
|
||
| export const MOCK_STATE_MACHINE_ARN = 'arn:aws:states:us-east-1:123456789012:stateMachine:MyWorkflow' | ||
| export const MOCK_REGION = 'us-east-1' | ||
| export const MOCK_CASE_ID = 'case-123456' | ||
| export const MOCK_EMAIL = 'test@example.com' | ||
| export const MOCK_API_KEY = 'test-api-key-1234' | ||
|
|
||
| export const MOCK_AWS_CREDENTIALS = { | ||
| accessKeyId: 'AKIAIOSFODNN7EXAMPLE', | ||
| secretAccessKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', | ||
| sessionToken: undefined, | ||
| } | ||
|
|
||
| export const MOCK_FRAMEWORK = 'Serverless Framework' | ||
|
|
||
| export const MOCK_OUTPUT_DIR = '.datadog-ci/flare/stepfunctions-MyWorkflow-1704106800000' | ||
|
|
||
| export const MOCK_INSIGHTS_CONTENT = `# Step Functions Flare Insights | ||
|
|
||
| Generated: 2024-01-01T10:00:00.000Z | ||
|
|
||
| ## State Machine Configuration | ||
| - Name: MyWorkflow | ||
| - ARN: arn:aws:states:us-east-1:123456789012:stateMachine:MyWorkflow | ||
| - Type: STANDARD | ||
| - Status: ACTIVE | ||
|
|
||
| ## Framework | ||
| Serverless Framework | ||
|
|
||
| ## Environment | ||
| - Region: us-east-1 | ||
| - CLI Version: 1.0.0 | ||
| ` |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestion for consistency -- as in line
5,Step Functionis used when it's an attributive noun