Parameters: EEKeyPair: Type: AWS::EC2::KeyPair::KeyName Default: EEKeyPair Description: Event Engine Name of the EC2 KeyPair generated for the Team LatestAMI: Type: AWS::SSM::Parameter::Value Default: /aws/service/ami-windows-latest/Windows_Server-2019-English-Full-Base Description: Latest AMI from windows Resources: CodeDeployServiceRole897ED2CE: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - Action: sts:AssumeRole Effect: Allow Principal: Service: Fn::Join: - "" - - codedeploy. - Ref: AWS::Region - "." - Ref: AWS::URLSuffix Version: "2012-10-17" ManagedPolicyArns: - arn:aws:iam::aws:policy/service-role/AWSCodeDeployRole Path: / Metadata: aws:cdk:path: CdkStack/CodeDeployServiceRole/Resource awscodestarservicerole60377864: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - Action: sts:AssumeRole Effect: Allow Principal: Service: codestar.amazonaws.com Version: "2012-10-17" ManagedPolicyArns: - arn:aws:iam::aws:policy/service-role/AWSCodeStarServiceRole Path: /service-role/ Metadata: aws:cdk:path: CdkStack/awscodestarservicerole/Resource awselasticbeanstalkserviceroleD8411EF4: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - Action: sts:AssumeRole Condition: StringEquals: sts:ExternalId: elasticbeanstalk Effect: Allow Principal: Service: elasticbeanstalk.amazonaws.com Version: "2012-10-17" ManagedPolicyArns: - arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkEnhancedHealth - arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkService Metadata: aws:cdk:path: CdkStack/awselasticbeanstalkservicerole/Resource CreateGitCredsRole385E94AC: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - Action: sts:AssumeRole Effect: Allow Principal: Service: lambda.amazonaws.com Version: "2012-10-17" Path: / Policies: - PolicyDocument: Statement: - Action: - iam:CreateServiceSpecificCredential - iam:ListServiceSpecificCredentials - iam:DeleteServiceSpecificCredential Effect: Allow Resource: "*" - Action: - logs:CreateLogGroup - logs:CreateLogStream - logs:PutLogEvents Effect: Allow Resource: arn:aws:logs:*:*:* Version: "2012-10-17" PolicyName: root Metadata: aws:cdk:path: CdkStack/CreateGitCredsRole/Resource DevAxNetworkVPC049CF20B: Type: AWS::EC2::VPC Properties: CidrBlock: 10.20.0.0/16 EnableDnsHostnames: true EnableDnsSupport: true InstanceTenancy: default Tags: - Key: Name Value: CdkStack/DevAxNetworkVPC Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/Resource DevAxNetworkVPCpublicSubnet1Subnet18336BFA: Type: AWS::EC2::Subnet Properties: CidrBlock: 10.20.0.0/24 VpcId: Ref: DevAxNetworkVPC049CF20B AvailabilityZone: Fn::Select: - 0 - Fn::GetAZs: "" MapPublicIpOnLaunch: true Tags: - Key: aws-cdk:subnet-name Value: public - Key: aws-cdk:subnet-type Value: Public - Key: Name Value: CdkStack/DevAxNetworkVPC/publicSubnet1 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet1/Subnet DevAxNetworkVPCpublicSubnet1RouteTable397546CD: Type: AWS::EC2::RouteTable Properties: VpcId: Ref: DevAxNetworkVPC049CF20B Tags: - Key: Name Value: CdkStack/DevAxNetworkVPC/publicSubnet1 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet1/RouteTable DevAxNetworkVPCpublicSubnet1RouteTableAssociation32F54607: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: Ref: DevAxNetworkVPCpublicSubnet1RouteTable397546CD SubnetId: Ref: DevAxNetworkVPCpublicSubnet1Subnet18336BFA Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet1/RouteTableAssociation DevAxNetworkVPCpublicSubnet1DefaultRoute088828A0: Type: AWS::EC2::Route Properties: RouteTableId: Ref: DevAxNetworkVPCpublicSubnet1RouteTable397546CD DestinationCidrBlock: 0.0.0.0/0 GatewayId: Ref: DevAxNetworkVPCIGW3AED8105 DependsOn: - DevAxNetworkVPCVPCGWBDEEED8F Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet1/DefaultRoute DevAxNetworkVPCpublicSubnet1EIP241549E0: Type: AWS::EC2::EIP Properties: Domain: vpc Tags: - Key: Name Value: CdkStack/DevAxNetworkVPC/publicSubnet1 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet1/EIP DevAxNetworkVPCpublicSubnet1NATGateway8B09B209: Type: AWS::EC2::NatGateway Properties: AllocationId: Fn::GetAtt: - DevAxNetworkVPCpublicSubnet1EIP241549E0 - AllocationId SubnetId: Ref: DevAxNetworkVPCpublicSubnet1Subnet18336BFA Tags: - Key: Name Value: CdkStack/DevAxNetworkVPC/publicSubnet1 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet1/NATGateway DevAxNetworkVPCpublicSubnet2Subnet0FE75CE7: Type: AWS::EC2::Subnet Properties: CidrBlock: 10.20.1.0/24 VpcId: Ref: DevAxNetworkVPC049CF20B AvailabilityZone: Fn::Select: - 1 - Fn::GetAZs: "" MapPublicIpOnLaunch: true Tags: - Key: aws-cdk:subnet-name Value: public - Key: aws-cdk:subnet-type Value: Public - Key: Name Value: CdkStack/DevAxNetworkVPC/publicSubnet2 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet2/Subnet DevAxNetworkVPCpublicSubnet2RouteTable697DCAB0: Type: AWS::EC2::RouteTable Properties: VpcId: Ref: DevAxNetworkVPC049CF20B Tags: - Key: Name Value: CdkStack/DevAxNetworkVPC/publicSubnet2 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet2/RouteTable DevAxNetworkVPCpublicSubnet2RouteTableAssociation88AA6DF8: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: Ref: DevAxNetworkVPCpublicSubnet2RouteTable697DCAB0 SubnetId: Ref: DevAxNetworkVPCpublicSubnet2Subnet0FE75CE7 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet2/RouteTableAssociation DevAxNetworkVPCpublicSubnet2DefaultRoute4C133366: Type: AWS::EC2::Route Properties: RouteTableId: Ref: DevAxNetworkVPCpublicSubnet2RouteTable697DCAB0 DestinationCidrBlock: 0.0.0.0/0 GatewayId: Ref: DevAxNetworkVPCIGW3AED8105 DependsOn: - DevAxNetworkVPCVPCGWBDEEED8F Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet2/DefaultRoute DevAxNetworkVPCpublicSubnet2EIP2C72517D: Type: AWS::EC2::EIP Properties: Domain: vpc Tags: - Key: Name Value: CdkStack/DevAxNetworkVPC/publicSubnet2 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet2/EIP DevAxNetworkVPCpublicSubnet2NATGateway63D3A4D0: Type: AWS::EC2::NatGateway Properties: AllocationId: Fn::GetAtt: - DevAxNetworkVPCpublicSubnet2EIP2C72517D - AllocationId SubnetId: Ref: DevAxNetworkVPCpublicSubnet2Subnet0FE75CE7 Tags: - Key: Name Value: CdkStack/DevAxNetworkVPC/publicSubnet2 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/publicSubnet2/NATGateway DevAxNetworkVPCprivateSubnet1SubnetF1C6C29A: Type: AWS::EC2::Subnet Properties: CidrBlock: 10.20.2.0/24 VpcId: Ref: DevAxNetworkVPC049CF20B AvailabilityZone: Fn::Select: - 0 - Fn::GetAZs: "" MapPublicIpOnLaunch: false Tags: - Key: aws-cdk:subnet-name Value: private - Key: aws-cdk:subnet-type Value: Private - Key: Name Value: CdkStack/DevAxNetworkVPC/privateSubnet1 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/privateSubnet1/Subnet DevAxNetworkVPCprivateSubnet1RouteTableF757820F: Type: AWS::EC2::RouteTable Properties: VpcId: Ref: DevAxNetworkVPC049CF20B Tags: - Key: Name Value: CdkStack/DevAxNetworkVPC/privateSubnet1 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/privateSubnet1/RouteTable DevAxNetworkVPCprivateSubnet1RouteTableAssociation94A46865: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: Ref: DevAxNetworkVPCprivateSubnet1RouteTableF757820F SubnetId: Ref: DevAxNetworkVPCprivateSubnet1SubnetF1C6C29A Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/privateSubnet1/RouteTableAssociation DevAxNetworkVPCprivateSubnet1DefaultRoute07EFC529: Type: AWS::EC2::Route Properties: RouteTableId: Ref: DevAxNetworkVPCprivateSubnet1RouteTableF757820F DestinationCidrBlock: 0.0.0.0/0 NatGatewayId: Ref: DevAxNetworkVPCpublicSubnet1NATGateway8B09B209 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/privateSubnet1/DefaultRoute DevAxNetworkVPCprivateSubnet2SubnetD148A816: Type: AWS::EC2::Subnet Properties: CidrBlock: 10.20.3.0/24 VpcId: Ref: DevAxNetworkVPC049CF20B AvailabilityZone: Fn::Select: - 1 - Fn::GetAZs: "" MapPublicIpOnLaunch: false Tags: - Key: aws-cdk:subnet-name Value: private - Key: aws-cdk:subnet-type Value: Private - Key: Name Value: CdkStack/DevAxNetworkVPC/privateSubnet2 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/privateSubnet2/Subnet DevAxNetworkVPCprivateSubnet2RouteTable81AEA059: Type: AWS::EC2::RouteTable Properties: VpcId: Ref: DevAxNetworkVPC049CF20B Tags: - Key: Name Value: CdkStack/DevAxNetworkVPC/privateSubnet2 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/privateSubnet2/RouteTable DevAxNetworkVPCprivateSubnet2RouteTableAssociation973AEB51: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: Ref: DevAxNetworkVPCprivateSubnet2RouteTable81AEA059 SubnetId: Ref: DevAxNetworkVPCprivateSubnet2SubnetD148A816 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/privateSubnet2/RouteTableAssociation DevAxNetworkVPCprivateSubnet2DefaultRouteE9B8CAFD: Type: AWS::EC2::Route Properties: RouteTableId: Ref: DevAxNetworkVPCprivateSubnet2RouteTable81AEA059 DestinationCidrBlock: 0.0.0.0/0 NatGatewayId: Ref: DevAxNetworkVPCpublicSubnet2NATGateway63D3A4D0 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/privateSubnet2/DefaultRoute DevAxNetworkVPCIGW3AED8105: Type: AWS::EC2::InternetGateway Properties: Tags: - Key: Name Value: CdkStack/DevAxNetworkVPC Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/IGW DevAxNetworkVPCVPCGWBDEEED8F: Type: AWS::EC2::VPCGatewayAttachment Properties: VpcId: Ref: DevAxNetworkVPC049CF20B InternetGatewayId: Ref: DevAxNetworkVPCIGW3AED8105 Metadata: aws:cdk:path: CdkStack/DevAxNetworkVPC/VPCGW DevAxNetworkSGF6BD3961: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: CdkStack/DevAxNetworkSG GroupName: DBSecurityGroup SecurityGroupEgress: - CidrIp: 0.0.0.0/0 Description: Allow all outbound traffic by default IpProtocol: "-1" SecurityGroupIngress: - CidrIp: 0.0.0.0/0 Description: from 0.0.0.0/0:3306 FromPort: 3306 IpProtocol: tcp ToPort: 3306 VpcId: Ref: DevAxNetworkVPC049CF20B Metadata: aws:cdk:path: CdkStack/DevAxNetworkSG/Resource DevAxNetworkSGfromCdkStackDevAxWindowsSecurityGroupE964B81F3306DE67D089: Type: AWS::EC2::SecurityGroupIngress Properties: IpProtocol: tcp Description: WorkshopHost to DB over mysql FromPort: 3306 GroupId: Fn::GetAtt: - DevAxNetworkSGF6BD3961 - GroupId SourceSecurityGroupId: Fn::GetAtt: - DevAxWindowsSecurityGroupDE999860 - GroupId ToPort: 3306 Metadata: aws:cdk:path: CdkStack/DevAxNetworkSG/from CdkStackDevAxWindowsSecurityGroupE964B81F:3306 DBinstanceSubnetGroupA78F1F9F: Type: AWS::RDS::DBSubnetGroup Properties: DBSubnetGroupDescription: Subnet group for DBinstance database SubnetIds: - Ref: DevAxNetworkVPCprivateSubnet1SubnetF1C6C29A - Ref: DevAxNetworkVPCprivateSubnet2SubnetD148A816 Metadata: aws:cdk:path: CdkStack/DBinstance/SubnetGroup/Default DBinstanceA5CF359B: Type: AWS::RDS::DBInstance Properties: DBInstanceClass: db.t2.small AllocatedStorage: "5" AutoMinorVersionUpgrade: false BackupRetentionPeriod: 3 CopyTagsToSnapshot: true DBName: travelbuddy DBSubnetGroupName: Ref: DBinstanceSubnetGroupA78F1F9F DeletionProtection: false Engine: mysql EngineVersion: "8.0" MasterUsername: root MasterUserPassword: labpassword MultiAZ: false Port: "3306" PubliclyAccessible: false StorageEncrypted: true StorageType: gp2 VPCSecurityGroups: - Fn::GetAtt: - DevAxNetworkSGF6BD3961 - GroupId UpdateReplacePolicy: Snapshot Metadata: aws:cdk:path: CdkStack/DBinstance/Resource AWSStudent3111CB37: Type: AWS::IAM::User Properties: UserName: awsstudent Metadata: aws:cdk:path: CdkStack/AWSStudent/Resource DevAxWindowsSecurityGroupDE999860: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: CdkStack/DevAxWindowsSecurityGroup GroupName: WorkspaceSecurityGroup SecurityGroupEgress: - CidrIp: 0.0.0.0/0 Description: Allow all outbound traffic by default IpProtocol: "-1" SecurityGroupIngress: - CidrIp: 0.0.0.0/0 Description: from 0.0.0.0/0:3389 FromPort: 3389 IpProtocol: tcp ToPort: 3389 VpcId: Ref: DevAxNetworkVPC049CF20B Metadata: aws:cdk:path: CdkStack/DevAxWindowsSecurityGroup/Resource DevAxWindowsHost: Type: AWS::EC2::Instance Properties: ImageId: Ref: LatestAMI InstanceType: m5.xlarge KeyName: Ref: EEKeyPair NetworkInterfaces: - AssociatePublicIpAddress: true DeviceIndex: "0" GroupSet: - Fn::GetAtt: - DevAxWindowsSecurityGroupDE999860 - GroupId SubnetId: Ref: DevAxNetworkVPCpublicSubnet1Subnet18336BFA SourceDestCheck: true Tags: - Key: Name Value: DevAxWindowsHost UserData: Fn::Base64: Fn::Sub: >- CreationPolicy: ResourceSignal: Count: 1 Timeout: PT60M Metadata: AWS::CloudFormation::Init: configSets: ascending: - setup - install - finalise setup: files: C:\setup\setenvironment.ps1: content: >- # Set execution policy and install chocolatey Set-ExecutionPolicy Bypass -Scope Process -Force [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) # Reload profile $env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.." Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" # Install Git choco install git -y --params="'/GitAndUnixToolsOnPath /NoAutoCrlf'" # Install AdoptOpenJDK jdk8 hotspot 8.262.10 https://chocolatey.org/packages/corretto8jdk choco install corretto8jdk -y refreshenv # Install IntelliJ https://chocolatey.org/packages/intellijidea-community choco install intellijidea-community -y # Install eclipse https://chocolatey.org/packages/eclipse choco install eclipse --version=4.15 -y --params "'/InstallationPath=C:\eclipse'" & "c:\\setup\\eclipseinstall.ps1" # Install Apache Maven https://chocolatey.org/packages/maven choco install maven -y # Install Tomcat https://chocolatey.org/packages/tomcat choco install tomcat -y # Install Python 3 https://chocolatey.org/packages/python3 choco install python3 -y refreshenv # Install AWS Cli 2 https://chocolatey.org/packages/awscli choco install awscli -y # Install Google Chrome https://chocolatey.org/packages/googlechrome choco install googlechrome -y --ignore-checksums # Install Elastic Beanstalk CLI pip install awsebcli --upgrade # Install MySQL Client https://chocolatey.org/packages/mysql-cli choco install mysql-cli # Move tomcat server to C:\ProgramData\Tomcat9 $tomcatPath = Get-ChildItem -Path C:\ProgramData\chocolatey\lib\Tomcat\tools -Directory | Select-Object -First 1 Get-ChildItem -Path $tomcatPath.FullName -Recurse | Move-Item -Destination C:\ProgramData\Tomcat9\ # Clear desktop $wshShell = New-Object -ComObject "WScript.Shell" Get-ChildItem -Path $wshShell.SpecialFolders.Item("AllUsersDesktop") -Recurse -ErrorAction SilentlyContinue | foreach { Remove-Item -Path $_.FullName } Get-ChildItem -Path $wshShell.SpecialFolders.Item("Desktop") -Recurse -ErrorAction SilentlyContinue | foreach { Remove-Item -Path $_.FullName } # Create shortcuts $wshShell = New-Object -ComObject "WScript.Shell" $urlShortcut = $wshShell.CreateShortcut( (Join-Path $wshShell.SpecialFolders.Item("AllUsersDesktop") "Dashboard.url") ) $urlShortcut.TargetPath = "https://dashboard.eventengine.run/login" $urlShortcut.Save() $wshShell = New-Object -ComObject "WScript.Shell" $urlShortcut = $wshShell.CreateShortcut( (Join-Path $wshShell.SpecialFolders.Item("AllUsersDesktop") "Workshop.url") ) $urlShortcut.TargetPath = "https://workshops.devax.academy/monoliths-to-microservices/" $urlShortcut.Save() C:\setup\eclipseinstall.ps1: content: > $eclipseBasePath = "C:\eclipse" $eclipseVer = Get-ChildItem -Path $eclipseBasePath -Force -Recurse | Select-Object -First 1 $eclipseDir = [IO.Path]::Combine($eclipseBasePath, $eclipseVer, 'eclipse\eclipse') # Install AWS Toolkit for eclipse & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.core.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.sdk.ui.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.ec2.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.dynamodb.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.identitymanagement.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.cloudformation.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.codecommit.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.codedeploy.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.codestar.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.elasticbeanstalk.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.lambda.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.opsworks.feature.feature.group | Out-Null & $eclipseDir -nosplash -application org.eclipse.equinox.p2.director -repository https://aws.amazon.com/eclipse -installIU com.amazonaws.eclipse.rds.feature.feature.group | Out-Null C:\setup\DB.sql: content: > # # Lab 1 - DB Seed Script # use travelbuddy; DROP TABLE IF EXISTS `flightspecial`; CREATE TABLE `flightspecial` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `header` varchar(255) NOT NULL DEFAULT '', `body` varchar(255) DEFAULT NULL, `origin` varchar(255) DEFAULT NULL, `originCode` varchar(6) DEFAULT NULL, `destination` varchar(255) DEFAULT NULL, `destinationCode` varchar(6) DEFAULT NULL, `cost` int(11) NOT NULL, `expiryDate` bigint(16) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 200), 'London to Prague', 'Jewel of the East', 'London', 'LHR', 'Paris', 'CDG' ); INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 200), 'Paris to London', 'Weekend getaway!', 'Origin', 'ORG', 'Destination', 'DST' ); INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 200), 'Dubai to Cairo', 'Middle East adventure', 'Origin', 'ORG', 'Destination', 'DST' ); INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 500), 'Melbourne to Hawaii', 'Escape to the sun this winter', 'Origin', 'ORG', 'Destination', 'DST' ); INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 200), 'Buenos Aires to Rio', 'Time to carnivale!', 'Origin', 'ORG', 'Destination', 'DST' ); INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 500), 'Sydney to Rome', 'An Italian classic', 'Origin', 'ORG', 'Destination', 'DST' ); INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 500), 'Melbourne to Sydney', 'Well trodden path', 'Origin', 'ORG', 'Destination', 'DST' ); INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 500), 'Hong Kong to Kuala Lumpur', 'Hop step and a jump', 'Origin', 'ORG', 'Destination', 'DST' ); INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 500), 'Lisbon to Madrid', 'Spanish adventure', 'Origin', 'ORG', 'Destination', 'DST' ); INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 500), 'Aswan to Cairo', 'An experience of a lifetime', 'Origin', 'ORG', 'Destination', 'DST' ); INSERT INTO `flightspecial` (`expiryDate`, `cost`, `header`, `body`, `origin`, `originCode`, `destination`, `destinationCode`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 500), 'New York to London', 'Trans-Atlantic', 'Origin', 'ORG', 'Destination', 'DST' ); #--------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------- DROP TABLE IF EXISTS `hotelspecial`; CREATE TABLE `hotelspecial` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `hotel` varchar(255) NOT NULL DEFAULT '', `description` varchar(255) DEFAULT NULL, `location` varchar(255) DEFAULT NULL, `cost` int(11) NOT NULL, `expiryDate` bigint(16) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'Sommerset Hotel', 'Minimum stay 3 nights', 'Sydney' ); INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'Freedmom Apartments', 'Pets allowed!', 'Sydney' ); INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'Studio City', 'Minimum stay one week', 'Los Angeles' ); INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'Le Fleur Hotel', 'Not available weekends', 'Los Angeles' ); INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'Classic Hotel', 'Includes breakfast', 'Dallas' ); INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'Groundhog Suites', 'Internet access included', 'Florida' ); INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'Sophmore Suites', 'Maximum 2 people per room', 'London' ); INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'Hotel Sandra', 'Minimum stay two nights', 'Cairo' ); INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'Apartamentos de Nestor', 'Pool and spa access included', 'Madrid' ); INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'Kangaroo Hotel', 'Maximum 2 people per room', 'Manchester' ); INSERT INTO `hotelspecial` (`expiryDate`, `cost`, `hotel`, `description`, `location`) VALUES ( (SELECT (UNIX_TIMESTAMP() * 1000)) + 79200 + (RAND() * 20000000), (50 + RAND() * 1000), 'EasyStay Apartments', 'Minimum stay one week', 'Melbourne' ); install: commands: runsetup: command: powershell.exe -ExecutionPolicy Unrestricted C:\setup\setenvironment.ps1 waitAfterCompletion: "0" seed: command: Fn::Sub: - C:\ProgramData\chocolatey\bin\mysql -h ${endpoint} -u ${user} -p${password} -P 3306 < C:\setup\DB.sql - endpoint: Fn::GetAtt: - DBinstanceA5CF359B - Endpoint.Address user: root password: labpassword waitAfterCompletion: "0" finalise: commands: cleanup: command: rmdir C:\setup /s /q waitAfterCompletion: "0" signal: command: Fn::Sub: cfn-signal.exe -e %ERRORLEVEL% --resource DevAxWindowsHost --stack ${AWS::StackName} --region ${AWS::Region} CreateGitCredsFunction9D6697C5: Type: AWS::Lambda::Function Properties: Code: ZipFile: > import boto3 import cfnresponse def lambda_handler(event,context): print(event) response = {} try: if event['RequestType'] == 'Delete': iam = boto3.client('iam') credentials = iam.list_service_specific_credentials(UserName='awsstudent',ServiceName='codecommit.amazonaws.com') serviceSpecificCredentialId = credentials['ServiceSpecificCredentials'][0]['ServiceSpecificCredentialId'] delete = iam.delete_service_specific_credential(UserName='awsstudent', ServiceSpecificCredentialId=serviceSpecificCredentialId) cfnresponse.send(event, context, cfnresponse.SUCCESS,response) else: iam = boto3.client('iam') gitcreds = iam.create_service_specific_credential(UserName='awsstudent',ServiceName='codecommit.amazonaws.com') response['GitUserName'] = gitcreds['ServiceSpecificCredential']['ServiceUserName'] response['GitPassword'] = gitcreds['ServiceSpecificCredential']['ServicePassword'] cfnresponse.send(event, context, cfnresponse.SUCCESS,response) except Exception as e: print(e) response['Status'] = 'FAILED' response['Reason'] = 'Git failed, see log for details' cfnresponse.send(event, context, cfnresponse.FAILED,response) Handler: index.lambda_handler Role: Fn::GetAtt: - CreateGitCredsRole385E94AC - Arn Runtime: python3.7 FunctionName: CreateGitCredsFunction MemorySize: 128 Timeout: 90 DependsOn: - CreateGitCredsRole385E94AC Metadata: aws:cdk:path: CdkStack/CreateGitCredsFunction/Resource GitCredsCR: Type: AWS::CloudFormation::CustomResource Properties: ServiceToken: Fn::GetAtt: - CreateGitCredsFunction9D6697C5 - Arn UpdateReplacePolicy: Delete DeletionPolicy: Delete Metadata: aws:cdk:path: CdkStack/GitCredsCR/Default CDKMetadata: Type: AWS::CDK::Metadata Properties: Modules: aws-cdk=1.74.0,@aws-cdk/assets=1.74.0,@aws-cdk/aws-applicationautoscaling=1.74.0,@aws-cdk/aws-autoscaling-common=1.74.0,@aws-cdk/aws-cloudwatch=1.74.0,@aws-cdk/aws-codeguruprofiler=1.74.0,@aws-cdk/aws-ec2=1.74.0,@aws-cdk/aws-events=1.74.0,@aws-cdk/aws-iam=1.74.0,@aws-cdk/aws-kms=1.74.0,@aws-cdk/aws-lambda=1.74.0,@aws-cdk/aws-logs=1.74.0,@aws-cdk/aws-rds=1.74.0,@aws-cdk/aws-s3=1.74.0,@aws-cdk/aws-s3-assets=1.74.0,@aws-cdk/aws-sam=1.74.0,@aws-cdk/aws-secretsmanager=1.74.0,@aws-cdk/aws-sqs=1.74.0,@aws-cdk/aws-ssm=1.74.0,@aws-cdk/cloud-assembly-schema=1.74.0,@aws-cdk/core=1.74.0,@aws-cdk/cx-api=1.74.0,@aws-cdk/region-info=1.74.0,jsii-runtime=node.js/v12.18.3 Metadata: aws:cdk:path: CdkStack/CDKMetadata/Default Condition: CDKMetadataAvailable Outputs: GitUserName: Description: Git Username Value: Fn::GetAtt: - GitCredsCR - GitUserName GitPassword: Description: Git Password Value: Fn::GetAtt: - GitCredsCR - GitPassword RDSEndpoint: Description: RDS database endpoint Value: Fn::GetAtt: - DBinstanceA5CF359B - Endpoint.Address Conditions: CDKMetadataAvailable: Fn::Or: - Fn::Or: - Fn::Equals: - Ref: AWS::Region - ap-east-1 - Fn::Equals: - Ref: AWS::Region - ap-northeast-1 - Fn::Equals: - Ref: AWS::Region - ap-northeast-2 - Fn::Equals: - Ref: AWS::Region - ap-south-1 - Fn::Equals: - Ref: AWS::Region - ap-southeast-1 - Fn::Equals: - Ref: AWS::Region - ap-southeast-2 - Fn::Equals: - Ref: AWS::Region - ca-central-1 - Fn::Equals: - Ref: AWS::Region - cn-north-1 - Fn::Equals: - Ref: AWS::Region - cn-northwest-1 - Fn::Equals: - Ref: AWS::Region - eu-central-1 - Fn::Or: - Fn::Equals: - Ref: AWS::Region - eu-north-1 - Fn::Equals: - Ref: AWS::Region - eu-west-1 - Fn::Equals: - Ref: AWS::Region - eu-west-2 - Fn::Equals: - Ref: AWS::Region - eu-west-3 - Fn::Equals: - Ref: AWS::Region - me-south-1 - Fn::Equals: - Ref: AWS::Region - sa-east-1 - Fn::Equals: - Ref: AWS::Region - us-east-1 - Fn::Equals: - Ref: AWS::Region - us-east-2 - Fn::Equals: - Ref: AWS::Region - us-west-1 - Fn::Equals: - Ref: AWS::Region - us-west-2