Skip to content

Commit 603b420

Browse files
Bob Strahangudivt
authored andcommitted
Update CloudFormation templates for GovCloud compatibility by replacing hardcoded amazonaws.com service principals with dynamic AWS::URLSuffix
1 parent 58a49bb commit 603b420

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

template.yaml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,6 +2661,111 @@ Resources:
26612661
SourceArn: !GetAtt WorkflowStateChangeRule.Arn
26622662

26632663
##########################################################################
2664+
# Step Functions Subscription Publisher
2665+
##########################################################################
2666+
StepFunctionSubscriptionPublisher:
2667+
Type: AWS::Serverless::Function
2668+
Metadata:
2669+
cfn_nag:
2670+
rules_to_suppress:
2671+
- id: W89
2672+
reason: "Function does not require VPC access as it only interacts with AWS services via APIs"
2673+
- id: W92
2674+
reason: "Function does not require reserved concurrency as it scales based on demand"
2675+
- id: W12
2676+
reason: "Lambda requires CloudWatch logs permissions"
2677+
# checkov:skip=CKV_AWS_116: "DLQ not required for subscription publisher function"
2678+
# checkov:skip=CKV_AWS_117: "Function does not require VPC access as it only interacts with AWS services via APIs"
2679+
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency as it scales based on demand"
2680+
# checkov:skip=CKV_AWS_173: "Environment variables do not contain sensitive data - only configuration values like feature flags and non-sensitive settings"
2681+
Properties:
2682+
PermissionsBoundary: !If [HasPermissionsBoundary, !Ref PermissionsBoundaryArn, !Ref AWS::NoValue]
2683+
CodeUri: src/lambda/stepfunction_subscription_publisher/
2684+
Handler: index.handler
2685+
Runtime: python3.12
2686+
Architectures:
2687+
- x86_64
2688+
MemorySize: 256
2689+
Timeout: 30
2690+
LoggingConfig:
2691+
LogGroup: !Ref StepFunctionSubscriptionPublisherLogGroup
2692+
Environment:
2693+
Variables:
2694+
APPSYNC_API_URL: !GetAtt GraphQLApi.GraphQLUrl
2695+
LOG_LEVEL: !Ref LogLevel
2696+
Policies:
2697+
- Statement:
2698+
- Effect: Allow
2699+
Action:
2700+
- states:DescribeExecution
2701+
- states:GetExecutionHistory
2702+
Resource:
2703+
- !Sub
2704+
- "arn:${AWS::Partition}:states:${AWS::Region}:${AWS::AccountId}:execution:${StateMachineName}*"
2705+
- StateMachineName: !If
2706+
- IsPattern3
2707+
- !GetAtt PATTERN3STACK.Outputs.StateMachineName
2708+
- !If
2709+
- IsPattern2
2710+
- !GetAtt PATTERN2STACK.Outputs.StateMachineName
2711+
- !GetAtt PATTERN1STACK.Outputs.StateMachineName
2712+
- Effect: Allow
2713+
Action:
2714+
- appsync:GraphQL
2715+
Resource:
2716+
- !Sub "${GraphQLApi.Arn}/types/Subscription/*"
2717+
- !Sub "${GraphQLApi.Arn}/types/Mutation/*"
2718+
- Effect: Allow
2719+
Action:
2720+
- kms:Encrypt
2721+
- kms:Decrypt
2722+
- kms:ReEncrypt*
2723+
- kms:GenerateDataKey*
2724+
- kms:DescribeKey
2725+
Resource: !GetAtt CustomerManagedEncryptionKey.Arn
2726+
2727+
StepFunctionSubscriptionPublisherLogGroup:
2728+
Type: AWS::Logs::LogGroup
2729+
Properties:
2730+
KmsKeyId: !GetAtt CustomerManagedEncryptionKey.Arn
2731+
RetentionInDays: !Ref LogRetentionDays
2732+
2733+
StepFunctionSubscriptionRule:
2734+
Type: AWS::Events::Rule
2735+
Properties:
2736+
EventPattern:
2737+
source:
2738+
- aws.states
2739+
detail-type:
2740+
- Step Functions Execution Status Change
2741+
detail:
2742+
stateMachineArn:
2743+
- !If
2744+
- IsPattern3
2745+
- !GetAtt PATTERN3STACK.Outputs.StateMachineArn
2746+
- !If
2747+
- IsPattern2
2748+
- !GetAtt PATTERN2STACK.Outputs.StateMachineArn
2749+
- !GetAtt PATTERN1STACK.Outputs.StateMachineArn
2750+
status:
2751+
- RUNNING
2752+
- SUCCEEDED
2753+
- FAILED
2754+
- TIMED_OUT
2755+
- ABORTED
2756+
Targets:
2757+
- Arn: !GetAtt StepFunctionSubscriptionPublisher.Arn
2758+
Id: "StepFunctionSubscriptionPublisher"
2759+
RetryPolicy:
2760+
MaximumRetryAttempts: 3
2761+
2762+
StepFunctionSubscriptionPublisherPermission:
2763+
Type: AWS::Lambda::Permission
2764+
Properties:
2765+
Action: lambda:InvokeFunction
2766+
FunctionName: !Ref StepFunctionSubscriptionPublisher
2767+
Principal: !Sub "events.${AWS::URLSuffix}"
2768+
SourceArn: !GetAtt StepFunctionSubscriptionRule.Arn
26642769

26652770
##########################################################################
26662771
# Optional Post Processing Lambda Hook

0 commit comments

Comments
 (0)