Michael a3edecf0c6
feat(AWS Lambda): Support for Amazon MQ RabbitMQ events (#9919)
Co-authored-by: Michael <michael@Michaels-MacBook-Pro.local>
Co-authored-by: Michael <michael@ip-192-168-158-61.eu-west-1.compute.internal>
2021-10-19 15:10:46 +02:00

298 lines
7.1 KiB
YAML

AWSTemplateFormatVersion: 2010-09-09
Parameters:
ClusterName:
Type: String
Description: Name of MSK Cluster
ActiveMQBrokerName:
Type: String
Description: Name of ActiveMQ Broker
ActiveMQUser:
Type: String
Description: Name of ActiveMQ User
ActiveMQPassword:
Type: String
Description: Password of ActiveMQ User
NoEcho: true
RabbitMQBrokerName:
Type: String
Description: Name of RabbitMQ Broker
RabbitMQUser:
Type: String
Description: Name of RabbitMQ User
RabbitMQPassword:
Type: String
Description: Password of RabbitMQ User
NoEcho: true
ClusterConfigurationArn:
Type: String
Description: MSK Cluster Configuration ARN
ClusterConfigurationRevision:
Type: Number
Description: MSK Cluster Configuration Revision number
Default: 1
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 172.31.0.0/16
Tags:
- Key: Name
Value: !Ref AWS::StackName
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ''
CidrBlock: 172.31.0.0/24
MapPublicIpOnLaunch: true
PrivateSubnetA:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ''
CidrBlock: 172.31.3.0/24
MapPublicIpOnLaunch: false
PrivateSubnetB:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: ''
CidrBlock: 172.31.2.0/24
MapPublicIpOnLaunch: false
InternetGateway:
Type: AWS::EC2::InternetGateway
GatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref VPC
InternetGatewayId: !Ref InternetGateway
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
PublicRoute:
Type: AWS::EC2::Route
DependsOn: GatewayAttachment
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
PublicSubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet
RouteTableId: !Ref PublicRouteTable
NatGateway:
Type: AWS::EC2::NatGateway
DependsOn: NatPublicIP
Properties:
AllocationId: !GetAtt NatPublicIP.AllocationId
SubnetId: !Ref PublicSubnet
NatPublicIP:
Type: AWS::EC2::EIP
DependsOn: VPC
Properties:
Domain: vpc
PrivateRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
PrivateRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref PrivateRouteTable
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway
PrivateSubnetARouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PrivateSubnetA
RouteTableId: !Ref PrivateRouteTable
PrivateSubnetBRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PrivateSubnetB
RouteTableId: !Ref PrivateRouteTable
ActiveMQSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security Group for ActiveMQ
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 61617
ToPort: 61617
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 61614
ToPort: 61614
CidrIp: 0.0.0.0/0
ActiveMQBroker:
Type: 'AWS::AmazonMQ::Broker'
Properties:
AutoMinorVersionUpgrade: 'false'
BrokerName: !Ref ActiveMQBrokerName
DeploymentMode: SINGLE_INSTANCE
EngineType: ActiveMQ
EngineVersion: '5.15.0'
HostInstanceType: mq.t2.micro
PubliclyAccessible: 'false'
SecurityGroups:
- !Ref ActiveMQSecurityGroup
SubnetIds:
- !Ref PrivateSubnetA
Users:
- ConsoleAccess: 'true'
Password: !Ref ActiveMQPassword
Username: !Ref ActiveMQUser
RabbitMQSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security Group for RabbitMQ
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 5671
ToPort: 5671
CidrIp: 0.0.0.0/0
RabbitMQBroker:
Type: 'AWS::AmazonMQ::Broker'
Properties:
AutoMinorVersionUpgrade: 'false'
BrokerName: !Ref RabbitMQBrokerName
DeploymentMode: SINGLE_INSTANCE
EngineType: RABBITMQ
EngineVersion: '3.8.11'
HostInstanceType: mq.t3.micro
PubliclyAccessible: 'false'
SecurityGroups:
- !Ref RabbitMQSecurityGroup
SubnetIds:
- !Ref PrivateSubnetA
Users:
- ConsoleAccess: 'true'
Password: !Ref RabbitMQPassword
Username: !Ref RabbitMQUser
MSKCluster:
Type: 'AWS::MSK::Cluster'
Properties:
ClusterName: !Ref ClusterName
KafkaVersion: 2.2.1
NumberOfBrokerNodes: 2
BrokerNodeGroupInfo:
InstanceType: kafka.t3.small
ClientSubnets:
- !Ref PrivateSubnetA
- !Ref PrivateSubnetB
StorageInfo:
EBSStorageInfo:
VolumeSize: 1
ConfigurationInfo:
Arn: !Ref ClusterConfigurationArn
Revision: !Ref ClusterConfigurationRevision
FileSystem:
Type: AWS::EFS::FileSystem
Properties:
PerformanceMode: generalPurpose
FileSystemTags:
- Key: Name
Value: ServerlessFrameworkTestsVolume
MountTarget:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref FileSystem
SubnetId: !Ref PrivateSubnetA
SecurityGroups:
- !GetAtt VPC.DefaultSecurityGroup
AccessPointResource:
Type: AWS::EFS::AccessPoint
Properties:
FileSystemId: !Ref FileSystem
PosixUser:
Uid: 1001
Gid: 1001
RootDirectory:
CreationInfo:
OwnerGid: 1001
OwnerUid: 1001
Permissions: 770
Path: /efs
Outputs:
VPC:
Description: VPC ID
Value: !Ref VPC
PrivateSubnetA:
Description: Private Subnet A ID
Value: !Ref PrivateSubnetA
SecurityGroup:
Description: Default security for Lambda VPC
Value: !GetAtt VPC.DefaultSecurityGroup
ActiveMQBrokerArn:
Description: Created ActiveMQ Broker ARN
Value: !GetAtt ActiveMQBroker.Arn
ActiveMQBrokerId:
Description: Created ActiveMQ Broker Id
Value: !Ref ActiveMQBroker
ActiveMQSecurityGroup:
Description: Security Group for ActiveMQ
Value: !Ref ActiveMQSecurityGroup
RabbitMQBrokerArn:
Description: Created RabbitMQ Broker ARN
Value: !GetAtt RabbitMQBroker.Arn
RabbitMQBrokerId:
Description: Created RabbitMQ Broker Id
Value: !Ref RabbitMQBroker
RabbitMQSecurityGroup:
Description: Security Group for RabbitMQ
Value: !Ref RabbitMQSecurityGroup
MSKCluster:
Description: Created MSK Cluster
Value: !Ref MSKCluster
EFSAccessPointARN:
Description: EFS Access Point ARN
Value: !GetAtt AccessPointResource.Arn