вам нужно установить загрузчик cfn и выполнить команды, попробуйте это
{
"Description":"AWS CloudFormation Sample Template EC2InstanceWithSecurityGroupSampleAndEBS",
"Resources":{
"Ec2Instance":{
"Metadata":{
"AWS::CloudFormation::Init":{
"configSets" : {
"InstallAndRun" : [ "config" ]
},
"config":{
"commands":{
"1_mkfs":{
"command":"mkfs -t ext4 /dev/xvdm\n"
},
"2_mkdir":{
"command":"mkdir /mntfirm\n"
},
"3_mount":{
"command":"mount /dev/xvdm /mntfirm"
}
}
}
}
},
"Type":"AWS::EC2::Instance",
"Properties":{
"ImageId":"AMI",
"InstanceType":"t1.micro",
"KeyName": "KEY",
"NetworkInterfaces":[
{
"GroupSet":[
"sg-xxx"
],
"AssociatePublicIpAddress":"true",
"DeviceIndex":"0",
"DeleteOnTermination":"true",
"SubnetId":"subnet-xxx"
}
],
"BlockDeviceMappings":[
{
"DeviceName":"/dev/sdm",
"Ebs":{
"VolumeType":"io1",
"Iops":300,
"DeleteOnTermination":true,
"VolumeSize":100
}
}
],
"UserData":{
"Fn::Base64":{
"Fn::Join":[
"",
[
"#!/bin/bash -xe\n",
"apt-get install -y python-setuptools\n",
"mkdir -p /opt/aws/bin\n",
"wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
"easy_install --script-dir /opt/aws/bin aws-cfn-bootstrap-latest.tar.gz\n",
"apt-get update\n",
"# Install the files and packages from the metadata\n",
"/opt/aws/bin/cfn-init -v ",
" --stack ",
{
"Ref":"AWS::StackName"
},
" --resource Ec2Instance ",
" --config InstallAndRun ",
" --region ",
{
"Ref":"AWS::Region"
},
"\n",
"# Signal the status from cfn-init\n",
"/opt/aws/bin/cfn-signal -e $? ",
" --stack ",
{
"Ref":"AWS::StackName"
},
" --resource Ec2Instance ",
" --region ",
{
"Ref":"AWS::Region"
},
"\n"
]
]
}
}
}
}
}
}
и все события будут записываться в системный журнал