@@ -33,7 +33,11 @@ Parameters:
3333 Default : https://github.com/aws-samples/serverless-patterns/
3434 ContactSchemaName :
3535 Type : String
36- Default : ContactSchema
36+ Default : ContactSchema
37+ GlueSchemaRegistryForMSKName :
38+ Type : String
39+ Default : GlueSchemaRegistryForMSK
40+
3741Conditions :
3842 CreateProvisionedCluster : !Equals
3943 - !Ref EnvType
@@ -271,13 +275,21 @@ Resources:
271275 FromPort : 22
272276 ToPort : 22
273277 SourceSecurityGroupId : !GetAtt KafkaClientInstanceSecurityGroup.GroupId
274-
278+
279+ MSKGlueRegistry :
280+ Type : AWS::Glue::Registry
281+ Properties :
282+ Name : !Ref GlueSchemaRegistryForMSKName
283+ Description : " Registry for storing schemas related to MSK"
284+
275285 ContactSchema :
276286 Type : AWS::Glue::Schema
277287 Properties :
278288 Name : !Ref ContactSchemaName
279289 Compatibility : BACKWARD
280290 DataFormat : AVRO
291+ Registry :
292+ Arn : !GetAtt MSKGlueRegistry.Arn
281293 SchemaDefinition : |
282294 {
283295 "type": "record",
@@ -543,11 +555,26 @@ Resources:
543555 cd ./serverless-patterns/msk-lambda-schema-avro-java-sam
544556 cp template_original.yaml template.yaml
545557 sudo chown -R ec2-user .
558+
559+ GLUE_SCHEMA_REGISTRY_NAME=${glue_registry_name}
560+ CONTACT_SCHEMA=${contact_schema_name}
561+ VPC_ID=${vpcid}
562+ LAMBDA_SECURITY_GROUP_ID={securitygroup}
563+ PRIVATE_SUBNET_1={privatesubnetone}
564+ PRIVATE_SUBNET_2={privatesubnettwo}
565+ PRIVATE_SUBNET_3={privatesubnetthree}
566+ SUBNET_IDS="$PRIVATE_SUBNET_1,$PRIVATE_SUBNET_2,$PRIVATE_SUBNET_3"
567+
546568 source /home/ec2-user/.bash_profile
547569 sed -i "s/CLUSTER_NAME/$CLUSTER_NAME/g" template.yaml
548570 sed -i "s/CLUSTER_ID/$CLUSTER_ID/g" template.yaml
549571 sed -i "s/KAFKA_TOPIC/$KAFKA_TOPIC/g" template.yaml
550572 sed -i "s/JAVA_VERSION/$JAVA_VERSION/g" template.yaml
573+ sed -i "s/GLUE_SCHEMA_REGISTRY_NAME/$GLUE_SCHEMA_REGISTRY_NAME/g" template.yaml
574+ sed -i "s/CONTACT_SCHEMA/$CONTACT_SCHEMA/g" template.yaml
575+ sed -i "s/VPC_ID/$VPC_ID/g" template.yaml
576+ sed -i "s/LAMBDA_SECURITY_GROUP_ID/$LAMBDA_SECURITY_GROUP_ID/g" template.yaml
577+ sed -i "s/SUBNET_IDS/$SUBNET_IDS/g" template.yaml
551578
552579 # Get IP CIDR range for EC2 Instance Connect
553580 cd /home/ec2-user
@@ -570,6 +597,14 @@ Resources:
570597 serverless_land_github_location : !Ref ServerlessLandGithubLocation
571598 aws_region : !Ref 'AWS::Region'
572599 java_version : !Ref JavaVersion
600+ vpcid : !Ref VPCId
601+ privatesubnetone : !Ref PrivateSubnetMSKOne
602+ privatesubnettwo : !Ref PrivateSubnetMSKTwo
603+ privatesubnetthree : !Ref PrivateSubnetMSKThree
604+ securitygroup : !Ref SecurityGroupId
605+ glue_registry_name : !Ref GlueSchemaRegistryForMSKName
606+ contact_schema_name : !Ref ContactSchemaName
607+
573608
574609 KafkaClientEC2InstanceServerless :
575610 Condition : CreateServerlessCluster
@@ -816,11 +851,27 @@ Resources:
816851 cd ./serverless-patterns/msk-lambda-schema-avro-java-sam
817852 cp template_original.yaml template.yaml
818853 sudo chown -R ec2-user .
854+
855+ GLUE_SCHEMA_REGISTRY_NAME=${glue_registry_name}
856+ CONTACT_SCHEMA=${contact_schema_name}
857+ VPC_ID=${vpcid}
858+ LAMBDA_SECURITY_GROUP_ID={securitygroup}
859+ PRIVATE_SUBNET_1={privatesubnetone}
860+ PRIVATE_SUBNET_2={privatesubnettwo}
861+ PRIVATE_SUBNET_3={privatesubnetthree}
862+ SUBNET_IDS="$PRIVATE_SUBNET_1,$PRIVATE_SUBNET_2,$PRIVATE_SUBNET_3"
863+
864+
819865 source /home/ec2-user/.bash_profile
820866 sed -i "s/CLUSTER_NAME/$CLUSTER_NAME/g" template.yaml
821867 sed -i "s/CLUSTER_ID/$CLUSTER_ID/g" template.yaml
822868 sed -i "s/KAFKA_TOPIC/$KAFKA_TOPIC/g" template.yaml
823869 sed -i "s/JAVA_VERSION/$JAVA_VERSION/g" template.yaml
870+ sed -i "s/GLUE_SCHEMA_REGISTRY_NAME/$GLUE_SCHEMA_REGISTRY_NAME/g" template.yaml
871+ sed -i "s/CONTACT_SCHEMA/$CONTACT_SCHEMA/g" template.yaml
872+ sed -i "s/VPC_ID/$VPC_ID/g" template.yaml
873+ sed -i "s/LAMBDA_SECURITY_GROUP_ID/$LAMBDA_SECURITY_GROUP_ID/g" template.yaml
874+ sed -i "s/SUBNET_IDS/$SUBNET_IDS/g" template.yaml
824875
825876 # Get IP CIDR range for EC2 Instance Connect
826877 cd /home/ec2-user
@@ -843,6 +894,15 @@ Resources:
843894 serverless_land_github_location : !Ref ServerlessLandGithubLocation
844895 aws_region : !Ref 'AWS::Region'
845896 java_version : !Ref JavaVersion
897+ vpcid : !Ref VPCId
898+ privatesubnetone : !Ref PrivateSubnetMSKOne
899+ privatesubnettwo : !Ref PrivateSubnetMSKTwo
900+ privatesubnetthree : !Ref PrivateSubnetMSKThree
901+ securitygroup : !Ref SecurityGroupId
902+ glue_registry_name : !Ref GlueSchemaRegistryForMSKName
903+ contact_schema_name : !Ref ContactSchemaName
904+
905+
846906
847907 EC2InstanceEndpoint :
848908 Type : AWS::EC2::InstanceConnectEndpoint
@@ -1215,6 +1275,9 @@ Resources:
12151275 SecurityGroups :
12161276 - !GetAtt MSKSecurityGroup.GroupId
12171277
1278+
1279+
1280+
12181281Outputs :
12191282 VPCId :
12201283 Description : The ID of the VPC created
0 commit comments