This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initData = ec2.CloudFormationInit.fromElements( | |
ec2.InitFile.fromAsset("c:\\cfn\\ContabBootstrapScript.ps1", "./ContabBootstrapScript.ps1"), | |
ec2.InitPackage.msi("https://s3.amazonaws.com/aws-cli/AWSCLI64.msi"), | |
ec2.InitCommand.shellCommand("powershell.exe -Command Rename-Computer (Get-EC2Tag -Filter @{Name='resource-id'; Values=(Invoke-WebRequest http://169.254.169.254/latest/meta-data/instance-id -UseBasicParsing).Content}).Where({$_.Key -eq 'Name'}).Value", { key: "2-RenameComputer", waitAfterCompletion: ec2.InitCommandWaitDuration.of(cdk.Duration.seconds(5)) }), | |
ec2.InitCommand.shellCommand('cfn-signal.exe -e %ERRORLEVEL% --resource contabmysqlinstance --stack '+this.stackId+' --region '+this.region, { key: "91-Signal", waitAfterCompletion: ec2.InitCommandWaitDuration.of(cdk.Duration.seconds(5))}) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//define the initData that will be used when creating the instance, this describes all the commands that will be ran on the instance | |
const initData = ec2.CloudFormationInit.fromElements( | |
// ec2.InitFile.fromUrl("c:\\cfn\\mysql.msi", "https://downloads.mysql.com/archives/get/p/25/file/mysql-installer-community-8.0.24.0.msi"), | |
ec2.InitFile.fromAsset("c:\\cfn\\BootstrapScript.ps1", "./BootstrapScript.ps1"), | |
ec2.InitFile.fromAsset("c:\\cfn\\CreateADGroups.ps1", "./CreateADGroups.ps1"), | |
ec2.InitPackage.msi("https://s3.amazonaws.com/aws-cli/AWSCLI64.msi"), | |
ec2.InitCommand.shellCommand('powershell.exe [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(\'https://chocolatey.org/install.ps1\'))', { key: "1-InstallChoco", waitAfterCompletion: ec2.InitCommandWaitDuration.of(cdk.Duration.seconds(5)) }), | |
ec2.InitCommand.shellCommand("powershell.exe -Command Rename-Computer (Get-EC2Tag -Filter @{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as cdk from '@aws-cdk/core'; | |
import * as ec2 from '@aws-cdk/aws-ec2'; // import ec2 library | |
import * as iam from '@aws-cdk/aws-iam'; | |
import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; | |
import * as elbvtargets from '@aws-cdk/aws-elasticloadbalancingv2-targets'; | |
import * as ssm from '@aws-cdk/aws-ssm'; | |
import * as kms from '@aws-cdk/aws-kms'; | |
export class InfraCdkappMysqlStack extends cdk.Stack { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initOptions: { | |
timeout: cdk.Duration.minutes(35), | |
ignoreFailures: true, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var deployInstance = true; | |
var instance: ec2.Instance; | |
if (deployInstance){ | |
//the instance and its related resources will be inside here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const targetDevice = '/dev/sdb'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cfn-signal.exe -e %ERRORLEVEL% --resource appmysqlserver --stack '+this.stackId+' --region '+this.region |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$AWS_AVAIL_ZONE=(Invoke-WebRequest http://169.254.169.254/latest/meta-data/placement/availability-zone -UseBasicParsing).Content | |
$AWS_REGION=$AWS_AVAIL_ZONE.Substring(0,$AWS_AVAIL_ZONE.length-1) | |
$AWS_INSTANCE_ID=(Invoke-WebRequest http://169.254.169.254/latest/meta-data/instance-id -UseBasicParsing).Content | |
$ROOT_VOLUME_IDS=((Get-EC2Instance -Region $AWS_REGION -InstanceId $AWS_INSTANCE_ID).Instances.BlockDeviceMappings | where-object DeviceName -match '/dev/sda1').Ebs.VolumeId | |
$instanceTags = Get-EC2Tag -Filter @{ Name="resource-id"; Values=$AWS_INSTANCE_ID} | |
$InstanceTagName = $instanceTags.Where({$_.Key -eq "Name"}).Value | |
$tag = New-Object Amazon.EC2.Model.Tag | |
$tag.key = "Name" | |
$tag.value = $InstanceTagName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws ssm create-document - content file://domainJoin.json - name "awsconfig_Domain_d-1234567890_test.example.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"schemaVersion": "1.0", | |
"description": "Sample config to join to domain", | |
"runtimeConfig": { | |
"aws:domainJoin": { | |
"properties": { | |
"directoryId": "d-1234567890", | |
"directoryName": "test.acme.com", | |
"directoryOU": "OU=test,DC=acme,DC=com", | |
"dnsIpAddresses": [ |
NewerOlder