There is an excellent user guide which is more to the point than much of anything I could write on the VPC
http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/default-vpc.html
Using Cloud Formation with a Beanstalk in a VPC, with both a pre-existing keypair and a pre-existing security group, requires adding the beanstalk into a pre-existing VPC - namely, the one which contains the security group. Thus, the beanstalk cloud formation template is altered with these options
"OptionSettings" : [ { "Namespace" : "aws:ec2:vpc", "OptionName" : "VPCId", "Value" : "vpc-eb8aae80" }, { "Namespace" : "aws:ec2:vpc", "OptionName" : "Subnets", "Value" : "subnet-e98aae82" }, { "Namespace" : "aws:autoscaling:launchconfiguration", "OptionName" : "SecurityGroups", "Value" : "sg-c7a86aa2" },
Click for the full file
Now the command I used to create the beanstalk is
aws cloudformation create-stack --stack-name Practice \ --template-body=file:///Users/mitchhan/aws-cli/tests/ElasticBeanstalkCustom.template \ --capabilities=CAPABILITY_IAM
ec2-describe-instances --filter "tag-value=Prac*"
ssh ec2-user@ec2-54-187-193-238.us-west-2.compute.amazonaws.com -i ~/.ssh/aws_rsaAnd I'm logged in. It worked. I check the process table with the ps command and I see tomcat is indeed running.
The next thing to add into cloud formation is the webapp war file I want deployed, and the RDS setup.
aws iam upload-server-certificate --server-certificate-name myServerCertificate --certificate-body \ file://public_key_cert_file.pem --private-key file://my_private_key.pem --certificate-chain \ file://my_certificate_chain_file.pem
aws iam list-server-certificatesTemplate documentation implies a property of ServerCertificateId, but the value needed in the cloudformation template for that is actually Arn from the above command, for example:
"Arn": "arn:aws:iam::479179999999:server-certificate/www.yourdomain.com"This blog also seems useful: