@@ -8,148 +8,63 @@ import { ResourceSchema } from '../../src/schema/ResourceSchema';
88import { SamSchemas } from '../../src/schema/SamSchemas' ;
99import { CloudFormationResourceSchema } from '../../src/schema/SamSchemaTransformer' ;
1010
11+ const loadSchema = ( name : string ) => readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , name ) , 'utf8' ) ;
12+
1113export const Schemas = {
12- S3Bucket : {
13- fileName : 'file://aws-s3-bucket.json' ,
14- get contents ( ) {
15- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-s3-bucket.json' ) , 'utf8' ) ;
16- } ,
17- } ,
18- EC2Instance : {
19- fileName : 'file://aws-ec2-instance.json' ,
20- get contents ( ) {
21- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-ec2-instance.json' ) , 'utf8' ) ;
22- } ,
23- } ,
24- IAMRole : {
25- fileName : 'file://aws-iam-role.json' ,
26- get contents ( ) {
27- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-iam-role.json' ) , 'utf8' ) ;
28- } ,
29- } ,
30- LambdaFunction : {
31- fileName : 'file://aws-lambda-function.json' ,
32- get contents ( ) {
33- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-lambda-function.json' ) , 'utf8' ) ;
34- } ,
35- } ,
36- EC2VPC : {
37- fileName : 'file://aws-ec2-vpc.json' ,
38- get contents ( ) {
39- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-ec2-vpc.json' ) , 'utf8' ) ;
40- } ,
41- } ,
42- EC2Subnet : {
43- fileName : 'file://aws-ec2-subnet.json' ,
44- get contents ( ) {
45- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-ec2-subnet.json' ) , 'utf8' ) ;
46- } ,
47- } ,
14+ S3Bucket : { fileName : 'file://aws-s3-bucket.json' , contents : loadSchema ( 'aws-s3-bucket.json' ) } ,
15+ EC2Instance : { fileName : 'file://aws-ec2-instance.json' , contents : loadSchema ( 'aws-ec2-instance.json' ) } ,
16+ IAMRole : { fileName : 'file://aws-iam-role.json' , contents : loadSchema ( 'aws-iam-role.json' ) } ,
17+ LambdaFunction : { fileName : 'file://aws-lambda-function.json' , contents : loadSchema ( 'aws-lambda-function.json' ) } ,
18+ EC2VPC : { fileName : 'file://aws-ec2-vpc.json' , contents : loadSchema ( 'aws-ec2-vpc.json' ) } ,
19+ EC2Subnet : { fileName : 'file://aws-ec2-subnet.json' , contents : loadSchema ( 'aws-ec2-subnet.json' ) } ,
4820 EC2SecurityGroup : {
4921 fileName : 'file://aws-ec2-securitygroup.json' ,
50- get contents ( ) {
51- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-ec2-securitygroup.json' ) , 'utf8' ) ;
52- } ,
22+ contents : loadSchema ( 'aws-ec2-securitygroup.json' ) ,
5323 } ,
5424 EC2LaunchTemplate : {
5525 fileName : 'file://aws-ec2-launchtemplate.json' ,
56- get contents ( ) {
57- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-ec2-launchtemplate.json' ) , 'utf8' ) ;
58- } ,
26+ contents : loadSchema ( 'aws-ec2-launchtemplate.json' ) ,
5927 } ,
6028 AutoScalingGroup : {
6129 fileName : 'file://aws-autoscaling-autoscalinggroup.json' ,
62- get contents ( ) {
63- return readFileSync (
64- join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-autoscaling-autoscalinggroup.json' ) ,
65- 'utf8' ,
66- ) ;
67- } ,
68- } ,
69- RDSDBInstance : {
70- fileName : 'file://aws-rds-dbinstance.json' ,
71- get contents ( ) {
72- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-rds-dbinstance.json' ) , 'utf8' ) ;
73- } ,
30+ contents : loadSchema ( 'aws-autoscaling-autoscalinggroup.json' ) ,
7431 } ,
32+ RDSDBInstance : { fileName : 'file://aws-rds-dbinstance.json' , contents : loadSchema ( 'aws-rds-dbinstance.json' ) } ,
7533 CloudWatchAlarm : {
7634 fileName : 'file://aws-cloudwatch-alarm.json' ,
77- get contents ( ) {
78- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-cloudwatch-alarm.json' ) , 'utf8' ) ;
79- } ,
80- } ,
81- SNSTopic : {
82- fileName : 'file://aws-sns-topic.json' ,
83- get contents ( ) {
84- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-sns-topic.json' ) , 'utf8' ) ;
85- } ,
86- } ,
87- SSMParameter : {
88- fileName : 'file://aws-ssm-parameter.json' ,
89- get contents ( ) {
90- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-ssm-parameter.json' ) , 'utf8' ) ;
91- } ,
35+ contents : loadSchema ( 'aws-cloudwatch-alarm.json' ) ,
9236 } ,
37+ SNSTopic : { fileName : 'file://aws-sns-topic.json' , contents : loadSchema ( 'aws-sns-topic.json' ) } ,
38+ SSMParameter : { fileName : 'file://aws-ssm-parameter.json' , contents : loadSchema ( 'aws-ssm-parameter.json' ) } ,
9339 DynamoDBGlobalTable : {
9440 fileName : 'file://aws-dynamodb-globaltable.json' ,
95- get contents ( ) {
96- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-dynamodb-globaltable.json' ) , 'utf8' ) ;
97- } ,
98- } ,
99- EC2SpotFleet : {
100- fileName : 'file://aws-ec2-spotfleet.json' ,
101- get contents ( ) {
102- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-ec2-spotfleet.json' ) , 'utf8' ) ;
103- } ,
41+ contents : loadSchema ( 'aws-dynamodb-globaltable.json' ) ,
10442 } ,
43+ EC2SpotFleet : { fileName : 'file://aws-ec2-spotfleet.json' , contents : loadSchema ( 'aws-ec2-spotfleet.json' ) } ,
10544 ELBv2ListenerRule : {
10645 fileName : 'file://aws-elasticloadbalancingv2-listenerrule.json' ,
107- get contents ( ) {
108- return readFileSync (
109- join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-elasticloadbalancingv2-listenerrule.json' ) ,
110- 'utf8' ,
111- ) ;
112- } ,
46+ contents : loadSchema ( 'aws-elasticloadbalancingv2-listenerrule.json' ) ,
11347 } ,
11448 ELBv2Listener : {
11549 fileName : 'file://aws-elasticloadbalancingv2-listener.json' ,
116- get contents ( ) {
117- return readFileSync (
118- join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-elasticloadbalancingv2-listener.json' ) ,
119- 'utf8' ,
120- ) ;
121- } ,
50+ contents : loadSchema ( 'aws-elasticloadbalancingv2-listener.json' ) ,
12251 } ,
12352 SecurityLakeSubscriberNotification : {
12453 fileName : 'file://aws-securitylake-subscribernotification.json' ,
125- get contents ( ) {
126- return readFileSync (
127- join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-securitylake-subscribernotification.json' ) ,
128- 'utf8' ,
129- ) ;
130- } ,
54+ contents : loadSchema ( 'aws-securitylake-subscribernotification.json' ) ,
13155 } ,
13256 SyntheticsCanary : {
13357 fileName : 'file://aws-synthetics-canary.json' ,
134- get contents ( ) {
135- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-synthetics-canary.json' ) , 'utf8' ) ;
136- } ,
58+ contents : loadSchema ( 'aws-synthetics-canary.json' ) ,
13759 } ,
13860} ;
13961
14062export const SamSchemaFiles = {
14163 ServerlessFunction : {
14264 fileName : 'file://aws-serverless-function.json' ,
143- get contents ( ) {
144- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-serverless-function.json' ) , 'utf8' ) ;
145- } ,
146- } ,
147- ServerlessApi : {
148- fileName : 'file://aws-serverless-api.json' ,
149- get contents ( ) {
150- return readFileSync ( join ( __dirname , '..' , 'resources' , 'schemas' , 'aws-serverless-api.json' ) , 'utf8' ) ;
151- } ,
65+ contents : loadSchema ( 'aws-serverless-function.json' ) ,
15266 } ,
67+ ServerlessApi : { fileName : 'file://aws-serverless-api.json' , contents : loadSchema ( 'aws-serverless-api.json' ) } ,
15368} ;
15469
15570export function regionalSchemas (
@@ -225,7 +140,7 @@ export function samFileType(
225140 return map ;
226141}
227142
228- export function getTestPrivateSchemas ( ) : DescribeTypeOutput [ ] {
143+ const testPrivateSchemas = ( ( ) => {
229144 const schemas : DescribeTypeOutput [ ] = [ ] ;
230145 const privateSchemasDir = join ( __dirname , '..' , 'resources' , 'private-schemas' ) ;
231146
@@ -242,4 +157,8 @@ export function getTestPrivateSchemas(): DescribeTypeOutput[] {
242157 }
243158
244159 return schemas ;
160+ } ) ( ) ;
161+
162+ export function getTestPrivateSchemas ( ) : DescribeTypeOutput [ ] {
163+ return testPrivateSchemas ;
245164}
0 commit comments