Reputation: 921
Also my application serve NPM React app as well as Flask backend with RDS attached. It is running Dualstack. I was able to track down that my website went 502 bad gateway. A minute after I created AMI image to copy Ec2 instance to my other account. For now I deployed the Instance and tried running(not running yet).
Cloud Trail log of AMI create
{
"eventVersion": "1.05",
"userIdentity": {
"type": "IAMUser",
"principalId": "",
"arn": "",
"accountId": "",
"accessKeyId": "",
"userName": "",
"sessionContext": {
"sessionIssuer": {},
"webIdFederationData": {},
"attributes": {
"mfaAuthenticated": "false",
"creationDate": "2019-09-13T02:30:45Z"
}
}
},
"eventTime": "2019-09-13T04:30:01Z",
"eventSource": "ec2.amazonaws.com",
"eventName": "CreateImage",
"awsRegion": "ap-southeast-2",
"sourceIPAddress": "***.66.79.65",
"userAgent": "console.ec2.amazonaws.com",
"requestParameters": {
"instanceId": "****05818a11a690e",
"name": "devport",
"description": "Port to Developer version of new one",
"noReboot": false,
"blockDeviceMapping": {
"items": [
{
"deviceName": "/dev/xvda",
"ebs": {
"volumeSize": 20,
"deleteOnTermination": true,
"volumeType": "gp2",
"encrypted": false
}
}
]
}
},
"responseElements": {
"requestId": "******-3cfb-49d0-917f-78641a0561cc",
"imageId": "ami-*****bfa644e5a043"
},
"requestID": "*****-3cfb-49d0-917f-78641a0561cc",
"eventID": "******-7780-4d61-900b-607378d7dc88",
"eventType": "AwsApiCall",
"recipientAccountId": ""
}
Upvotes: 1
Views: 474
Reputation: 60066
When creating AMI from instance it has two option either reboot during the creation of AMI or either do it the fly but the second one is not recommended.
So if you did not check the 502 bad gateway is expected until you restart your container if it did not restart automatically.
You can only share AMI when its ready state.
So at step 4 it reboot the instance and after step 5 it ready to share.
noReboot (Boolean)
By default this property is set to false, which means Amazon EC2 attempts to cleanly shut down the instance before image creation and reboots the instance afterwards. When set to true, Amazon EC2 does not shut down the instance before creating the image. When this option is used, file system integrity on the created image cannot be guaranteed. Default is FALSE.
Upvotes: 2