Skip to content

Instantly share code, notes, and snippets.

@kritro
Created September 30, 2021 09:37
Show Gist options
  • Save kritro/ea5b1b3a8132c399419fbac44b62d776 to your computer and use it in GitHub Desktop.
Save kritro/ea5b1b3a8132c399419fbac44b62d776 to your computer and use it in GitHub Desktop.
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))})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment