@@ -3,7 +3,7 @@ import { GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts";
3
3
import * as eventual from "@eventual/aws-cdk" ;
4
4
import { DebugDashboard , ServiceDashboard } from "@eventual/aws-cdk" ;
5
5
import { LogLevel } from "@eventual/core" ;
6
- import { App , CfnOutput , CfnResource , Stack } from "aws-cdk-lib" ;
6
+ import { App , CfnOutput , Stack } from "aws-cdk-lib" ;
7
7
import { AttributeType , BillingMode , Table } from "aws-cdk-lib/aws-dynamodb" ;
8
8
import {
9
9
ArnPrincipal ,
@@ -13,11 +13,20 @@ import {
13
13
} from "aws-cdk-lib/aws-iam" ;
14
14
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs" ;
15
15
import { Queue } from "aws-cdk-lib/aws-sqs" ;
16
- import { Duration } from "aws-cdk-lib/core" ;
16
+ import { Aspects , Duration } from "aws-cdk-lib/core" ;
17
+ import {
18
+ AwsSolutionsChecks ,
19
+ HIPAASecurityChecks ,
20
+ NagPack ,
21
+ NagPackProps ,
22
+ NagReportFormat ,
23
+ } from "cdk-nag" ;
17
24
import { createRequire as topLevelCreateRequire } from "module" ;
18
25
import path from "path" ;
19
26
import { ChaosExtension } from "./chaos-extension.js" ;
20
27
28
+ import { ComplianceStandard } from "@eventual/aws-cdk" ;
29
+ import { CfnPipe } from "aws-cdk-lib/aws-pipes" ;
21
30
import type * as testServiceRuntime from "tests-runtime" ;
22
31
23
32
const require = topLevelCreateRequire ( import . meta. url ) ;
@@ -56,6 +65,9 @@ const testService = new eventual.Service<typeof testServiceRuntime>(
56
65
TEST_QUEUE_URL : testQueue . queueUrl ,
57
66
TEST_TABLE_NAME : testTable . tableName ,
58
67
} ,
68
+ compliance : {
69
+ standards : [ ComplianceStandard . HIPAA ] ,
70
+ } ,
59
71
system : {
60
72
workflowService : {
61
73
logLevel : LogLevel . DEBUG ,
@@ -79,6 +91,27 @@ const testService = new eventual.Service<typeof testServiceRuntime>(
79
91
}
80
92
) ;
81
93
94
+ // these run linting rules on the CDK code and should all pass to enforce compliance
95
+ enableNagPack ( AwsSolutionsChecks ) ;
96
+ enableNagPack ( HIPAASecurityChecks ) ;
97
+ function enableNagPack < P extends NagPackProps > (
98
+ Pack : new ( props : P ) => NagPack ,
99
+ props ?: P
100
+ ) {
101
+ // TODO: enable once we comply with all policies and tests pass in deployment
102
+ const nag = false ;
103
+ if ( nag ) {
104
+ Aspects . of ( testService ) . add (
105
+ new Pack ( {
106
+ reports : true ,
107
+ reportFormats : [ NagReportFormat . CSV , NagReportFormat . JSON ] ,
108
+ verbose : true ,
109
+ ...props ,
110
+ } as P )
111
+ ) ;
112
+ }
113
+ }
114
+
82
115
testService . grantInvokeHttpServiceApi ( role ) ;
83
116
testService . system . accessRole . grantAssumeRole ( role ) ;
84
117
eventual . Service . grantDescribeParameters ( stack , role ) ;
@@ -128,18 +161,15 @@ asyncWriterFunction.grantInvoke(pipeRole);
128
161
testService . grantInvokeHttpServiceApi ( asyncWriterFunction ) ;
129
162
130
163
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-pipes-pipe.html
131
- new CfnResource ( stack , "pipe" , {
132
- type : "AWS::Pipes::Pipe" ,
133
- properties : {
134
- TargetParameters : {
135
- InputTemplate :
136
- '{"token": "<$.body.token>","type":"<$.body.type>","ingestionTime":"<aws.pipes.event.ingestion-time>"}' ,
137
- } ,
138
- Name : stack . stackName + "_pipe" ,
139
- RoleArn : pipeRole . roleArn ,
140
- Source : testQueue . queueArn ,
141
- Target : asyncWriterFunction . functionArn ,
164
+ new CfnPipe ( stack , "pipe" , {
165
+ targetParameters : {
166
+ inputTemplate :
167
+ '{"token": "<$.body.token>","type":"<$.body.type>","ingestionTime":"<aws.pipes.event.ingestion-time>"}' ,
142
168
} ,
169
+ name : stack . stackName + "_pipe" ,
170
+ roleArn : pipeRole . roleArn ,
171
+ source : testQueue . queueArn ,
172
+ target : asyncWriterFunction . functionArn ,
143
173
} ) ;
144
174
145
175
new ServiceDashboard ( stack , "dashboard" , {
0 commit comments