CodeDeploy with VPC endpoint on private subnet instances - amazon-web-services

I am trying to use CodeDeploy to deploy my revisions on private subnet instances using VPC endpoint.
VPC endpoint is having required subnet configured and security group applied on VPC endpoint is having all inbound and outbound allowed. Still my deployment is failing and I do not have any way to check logs on EC2 instance since it is private. Any help or guidance regarding this?
I am trying to follow the below link:
https://aws.amazon.com/about-aws/whats-new/2020/08/aws-codedeploy-now-supports-deployments-to-virtual-private-cloud-endpoints/

Related

AWS ECS: Issue when access external network

I have an issue regarding to AWS VPC networking, I want to access external API from my ECS task, I've configured ECS in a Private subnet and the only way to access this ECS is trough an load balancer, in some services like Lambda is working (I can access external resources) but in ECS I can't access to them, I tried modifying the security group rules + modify ACL rules but isn't working, If anyone know how I can do, I be very grateful, thanks.
ps: I created the VPC on the UI that AWS has.
For resources in a private subnet to access the Internet, the only option is to send that traffic through a NAT Gateway.
You will have to create an AWS NAT Gateway in at least one of the public subnets of your VPC, and then add a route in each of the private subnets to that NAT Gateway.

Problem with attaching of internet gateway - Terraform

I have problems with assigning two internet gateways in the infrastructure with terraform.
I have two subnets, a subnet manages all the frontend and the other subnets manages all the backend, i want to assign them an internet gateway to each ec2 instance so to can use them from the internet, but I'm getting the next error:
error attaching EC2 Internet Gateway (igw-0b0af7a9d5274c29d) to VPC (vpc-095fd5e0ee29b981d): InvalidParameterValue: Network vpc-095fd5e0ee29b981d already has an internet gateway attached
It is not possible to attach more than one InternetGateway per VPC. For ec2 instances to access the internet, add rote to your subnet's route table that directs all default traffic (0.0.0.0/0) to your InternetGateway. Also assign Public IP / Elastic IP to each of EC2.
Refer this AWS doc for more info:-
https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html

Connect to RDS (in VPC), from outside VPC, via VPC Endpoint (AWS)

I've spend about a full day trying to solve this, but have no luck so far. I'm also open to alternative suggestions than my current setup.
I have an RDS instance inside of a VPC. I am trying to make CodeBuild be able to access this RDS instance for a testing step.
Currently, I setup a VPC endpoint for the CodeBuild service, with all 3 subnets of the VPC. I know that if I allow all inbound traffic for the security group on the RDS, it works. I don't want to allow all inbound traffic though- and given this, have been unsuccessful.
I have tried the following to no avail:
Taking the private IPv4's of the ENI's created by the VPCE, adding them as inbound rules to the security group on the RDS
Creating a separate VPC for CodeBuild, and setup VPC peering (this seemed overly complex, and I'm not sure if the peering would even allow CodeBuild traffic to hit an RDS; it also makes things complicated down the road for CodeDeploy).
Putting CodeBuild inside the VPC of the RDS instance. When doing this, I created a new subnet in the VPC, assigned it to a NAT in the routes table (and this NAT was on the VPC of the RDS instance); put CodeBuild kept telling me it had no internet access.
setup a VPC endpoint for the CodeBuild service,
VPC endpoints are not used for inbound traffic from CB to VPC. They are used for your applications in VPC to interact with CB service without the internet.
Putting CodeBuild inside the VPC of the RDS instance.
This is the correct way. Sadly you haven't provided any details of your VPC, subents, NAT, route tables, security groups, NACLs setup, thus its difficult to speculate why it does not work.
Thanks Marcin for pointing me in the right direction to make CodeBuild in the same VPC. When I was able to focus on that, I saw this post again:
CodeBuild cannot find the 0.0.0.0/0 destination for the target internet gateway
which I had the same issue; my NAT was also on the private subnet. Now, it's on the public subnet, and it's working.

AWS lambda VPC cannot reach internet with IG attached

I have an AWS lambda function that makes a request to the internet. When it makes the request with NO VPC, it's ok, but when I add it to the VPC, it stops working. I've attached an Internet Gateway to the VPC and created a NAT Gateway with RT to use outbound 0.0.0.0/0, but it stills not working.
With the 15seconds timeout, it's always throwing TO.
Could you please help me?
I've already followed these sites:
https://gist.github.com/reggi/dc5f2620b7b4f515e68e46255ac042a7
http://derpturkey.com/lambda-vpc-and-internet-access-configuration/
Everything seems to be well configured.
Lambda configuration
Route Table configuration
IGW attached to VPC
There are three ways to grant Internet access to an AWS Lambda function:
Do not assign it a VPC, or
Assign it to a VPC and attach an Elastic IP Address to the ENI (Elastic Network Interface) that is created in the VPC, or
Assign it to a private subnet in a VPC and use a NAT Gateway to grant the private subnet access to the Internet
If you have already verified the network configurtions like VPC setup, Subnets, Route Table, IG/NAG gate way. And associated the Lambda with current subnet and security groups.
Then the last thing to verify would be:
For Lambda functions to work into custom or User Defined VPC, Adding Lambda to the VPC would require AWSLambdaVPCAccessExecutionRole in addition to AWSLambdaBasicExecutionRole.
Ensure that the associated role has the above permissions.
Source:
https://docs.aws.amazon.com/lambda/latest/dg/vpc-rds-create-iam-role.html

AWS VPC: Sample Scenario 1 - no internet access from EC2 instance without EIP

i following the steps mentioned in the "Scenario 1" tutorial of AWS VPC.
http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Scenario1.html
Withing the public subnet if have an OpenSVN server which allows VPN connections to the VPC.
The server has a EIP assigned. There are no problems accessing the VPC via VPN.
If i add other EC2 instances to the VPC without a EIP the don't have access to the internet!
I have a internet gateway configured, and my route table only contains the net-local rule and the 0.0.0.0 -> internet-gateway one.
Any ideas what's missing?
If i attach an EIP to the instance, it works.
Thanks
Jens
During all the VPC tutorial testing i deleted my "default vpc".
Without the default VPC, the EC2 instances will not get a public IP.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-vpc.html
https://serverfault.com/questions/509136/how-do-i-set-a-vpc-in-aws-to-default-vpc-true
I have to contact the amazon support.
Update: There is a (new?) option in the awscli which solve the problem --associate-public-ip-address
http://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html