EC2 - Remove EC2 from VPC - amazon-web-services

I was wondering if it's possible to remove an ec2 instance from VPC. If so, how can i do it? I was doing some tests and and i would like to remove my instances without terminate all of them.
Thank in advance.

You cannot move an instance between VPC and non-VPC, only launch new instances.
The 'opposite' of VPC is called EC2 Classic. As you can tell by the name, Amazon is depreciating this mode. All new accounts since December 2013 are VPC only. Several new features only work in VPC (for example, 'Enhanced Networking').
The writing is on the wall: You will need to move to VPC sooner or later. During the migration, you can use EC2 ClassicLink to let your EC2 Classic boxes talk with boxes in your VPC groups.

Remeber that when you create an instance, you specify the VPC that it will be launched in. It is not possible to change the VPC without terminating the instance and re-launching it in the new one.
One possible option would be to create an AMI of your currently running instance, and relaunch it in your preferred VPC using that AMI.

Related

My VPC is greyed out when trying to create a EC2 Instance?

I am trying to create an instance into my already created VPC network. For some reason when I am in the middle of the launch, I cannot select my VPC and it only lets me select a default VPC which is not what I want.
The reason for grey-out is because the VPC is created with "dedicated" tenancy. Changing the VPC to"default" tenancy will solve the issue. Apparently, there is no option to make that change in the AWS GUI. Either you have to delete and re-create the VPC with default tenancy or modify the tenancy value using the AWS CLI.
To modify the instance tenancy attribute of a VPC using the AWS CLI
Use the modify-vpc-tenancy command to specify the ID of the VPC and instance tenancy value. The only supported value is default.
aws ec2 modify-vpc-tenancy --vpc-id vpc-1a2b3c4d --instance-tenancy default
Alright so the solution was that the AMI was not compatible with my Dedicated Tenancy on my VPC so I had to delete and redo the entire VPC as default instead of Dedicated.
You probably does not have any Subnet private or public in your VPC can you please confirm?
I want to also point out that the AZ may not have any instances of that TYPE available. This will cause the VPC to be greyed out as well. I was trying to create a t2.medium or below in us-east-1c and I was seeing my VPC greyed out until I changed to an M or T3 type.

Is there any way to replicate our AWS EC2 instances without using Auto-scaling option?

Thanks in advance....
we have RDS replication with multi-AZ option. Is there any way to replicate our AWS EC2 instances without using Auto-scaling option?
On the EC2 console listing running instances, select the instance you want to replicate and under Actions click Launch More Like This.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/launch-more-like-this.html
Yes, configure your EC2 instance exactly the way you want it to be. Stop the instance and create an AMI of this instance. Then launch as many EC2 instances as you want using the AMI. Each EC2 instance will be almost identical. There will be differences due to licensing, IP addressing, instance ID, etc.
This is the same technique that you would use with Auto Scaling Groups (e.g. new instances are launched from a specific AMI).
Another option is to use Launch More Like This from the EC2 Console. However, this feature does not clone your instance, only replicates some configuration details.

Using an AWS RDS instance across multiple VPC

I have one VPC with an RDS instance in it. They are both located in the same region.
I want to use the RDS instance in another VPC, that is in another region on another AWS account (we have multiple AWS accounts). If that's not complicated enough the 2nd VPC comes up via CloudFormation (i.e. dynamic). Whenever I am bringing up a CloudFormation stack I want to attach the RDS instance automatically.
I have looked at:
exposing the RDS instance on the public internet :(
an ELB w/ TCP transport to put the database instance behind
VPC peering but the different regions and the approval workflow in the AWS console make little sense in the case we are using CloudFormation
All of these seem suboptimal to me and was wondering if somebody already did this before. If yes, please share what you did and what the though process behind it was.
Use a VPN tunnel from one VPC to the other. You could build your own or look at Vyatta. Ideally the two VPCs do not have overlapping CIDRs. Note that you cannot use VPC peering inter-region.
For anyone who stumbles around here, it looks like AWS VPC Peering can now be done cross region: https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html

Secure interaction between VPC and EC2-Classic instances

I am faced with a chicken and egg problem. I currently have a server in EC2 classic, as well as an RDS instance -- in EC2 classic as well. The EC2 instances also interact with Cassandra cluster, which also resides in EC2 classic.
However, I need to move RDS into the VPC. Now, in an ideal world, I'd have all of my stuff in VPC at this point. However, that presents a major migration challenge and I'd like to minimize impact on users and keep steps to minimum -- this is mainly because of the Cassandra cluster.
It turns out that I cannot create security group rules between VPC and Non-VPC security groups.
So, how can I have RDS in VPC that my EC2 instances can access w/o having to open up my RDS to the entire world ?
Any help is greatly appreciated.
UPDATE: So, one idea I had is to assign elastic IPs to my EC2 instances and add IPs explicitly to the security group for RDS within VPC. Would that work ? (trying it now using https://github.com/skymill/aws-ec2-assign-elastic-ip)
Yes, unfortunately that's the only way to do it. You cannot use DNS in security groups, so you're stuck with IP address.
So, I ended up solving it exactly like I described -- assign elastic IPs to my EC2 instances and add IPs explicitly to the security group for RDS within VPC. It ended up working great.

AWS - moving RDS to VPC

We have couple of RDS that are not added under VPC, so we need to bring them under VPC. Please let me know the steps and downtime expected. Also let me know if there need to be any changes in the webservers, so that everything works fine after RDS is under VPC.
You must have a VPC created before hand that have subnet in atleast two different regions.
After this go and create a "subnet group" for RDS and add two existing subnet in that.
Next take a snapshot of your RDS instance and start a new RDS instance from snapshot in VPC.
That should be it.
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.html#USER_VPC.Non-VPC2VPC - official documentation from Amazon.
Depending on your configuration and if the RDS needs to be accessible from the Internet you will have to check the option "Publicly Accessible" in the creation wizard and (in addition to the subnets mentioned in other answers) ensure that the Security has port for the DB properly enabled (and maybe from 0.0.0.0/0).