Unable to establish connection to jdbc:mysql communication link failure - amazon-rds

I've been trying to set up a data pipeline between an S3 bucket and an Elasitcbeanstalk environment which includes a MySQL RDS instance (all in the same VPC).
I get the failure:
The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server.
amazonaws.datapipeline.database.ConnectionFactory: Unable to establish
connection to jdbc:mysql://***.us-west-2.rds.amazonaws.com:3306/mydata
Communications link failure
I believe the problem is that I need to allow the data pipeline to access my MySQL RDS, but can't figure out how. I set myEc2RdsSecurityGrps field to the security group name listed for the RDS instance under EC2 > Security Groups, but that didn't help.
The RDS instance has the value IAM DB Authentication Enabled set to Yes.
Also, very new to IAM roles here but two were created like so: Roles > Create Role > Data Pipeline > EC2 Role for Data Pipeline (Provides access to S3, DynamoDB, and other services for EC2 instances that Data Pipeline launches) and also Roles > Create Role > Data Pipeline > Data Pipeline (Allows Data Pipeline and Data Pipeline managed EMR clusters to call AWS services on your behalf).
Am I missing a step?

The Security for the RDS instance should have the DB port open to the security group of the EC2 task runners in the Datapipeline.
To create a security group for an EC2 instance in a VPC
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, click Security Groups.
Click Create Security Group.
Specify a name and description for the security group.
Select your VPC from the list, and then click Create.
Note the ID of the new security group.
If you are running Task Runner on your own computer, note its public IP address, in CIDR notation. If the computer is behind a firewall, note the entire address range of its network. You'll need this address later on.
Next, create rules in the resource security groups that allow inbound traffic for the data sources Task Runner must access. For example, if Task Runner must access a Amazon Redshift cluster, the security group for the Amazon Redshift cluster must allow inbound traffic from the resource.
To add a rule to the security group for an RDS database
Open the Amazon RDS console at https://console.aws.amazon.com/rds/.
In the navigation pane, click Instances.
Click the details icon for the DB instance. Under Security and Network, click the link to the security group, which takes you to the Amazon EC2 console. If you're using the old console design for security groups, switch to the new console design by clicking the icon that's displayed at the top of the console page.
From the Inbound tab, click Edit and then click Add Rule.
Specify the database port that you used when you launched the DB instance. Start typing the ID of the security group or IP address used by the resource running Task Runner in Source.
Click Save.
http://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-resources-vpc.html#dp-vpc-security-groups

In AWS-RDS, Security Group, The Inbound Source should have the IP address you are trying to access the DB from or should be made 'Anywhere'
1) Open the Amazon RDS console at https://console.aws.amazon.com/rds/
2) In the navigation pane, click Instances.
3) Click the details icon for the DB instance. Under Security and Network, click the link to the security group, which takes you to the Amazon EC2 console. If you're using the old console design for security groups, switch to the new console design by clicking the icon that's displayed at the top of the console page.
4) From the Inbound tab, click Edit (a pop-up will open)
5) In the Source field click on the dropdown and select 'Anywhere', the IP address by default will be selected as '0.0.0.0/0, ::/0' or make select 'Custom' and enter the IP address from which you are accessing the DB from (or '0.0.0.0/0, ::/0' which is same as 'Anywhere').

Related

Changing a VM Network Security Group from Azure Portal

I am trying to change the network security group in a VM, from azure portal.
From azure portal and going to Networking, I can see the actual network security group ("mygroup1"). I want to change it to "mygroup2".
If I press the Network security group name I can navigate to the azure portal but I cannot see the way to change the actual Network security group from my VM to a new existing one.
EDIT: The VM is connected. I suspect to do this I also have to shut it down I guess.
Can anyone help?
You cannot change the network security group in a VM, instead:
You can associate a network security group to, or dissociate a network security group from a network interface.
https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-network-interface#associate-or-dissociate-a-network-security-group
In the search box at the top of the portal, enter network interfaces in the search box. When network interfaces appear in the search results, select it.
Select the network interface in the list that you want to associate a network security group to, or dissociate a network security group from.
Select Network security group under SETTINGS.
Select Edit.
Select Network security group and then select the network security group you want to associate to the network interface, or select None, to dissociate a network security group. Save
You can Associate a network security group to, or dissociate a network security group from a subnet. https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-manage-subnet#change-subnet-settings
Go to the Azure portal to view your virtual networks. Search for and select Virtual networks.
Select the name of the virtual network containing the subnet you want to change.
From Settings, select Subnets.
In the list of subnets, select the subnet you want to change settings for.
In the subnet page, change any of the following settings: Network security group
Click Save

AWS SSM sessions manager doesn't work for private instances with NACL configured

I am unable to use AWS SSM sessions manager for secure login to my private instances with NACL rules applied. Whereas AWS SSM works if I update NACL rules open To public(0.0.0.0/0).I want my private instances to be secure and not have open connections in NACL.
Please help.
I want my private instances to be secure and not have open connections
To use AWS SSM in a completely private subnet that has no inbound or outbound access to the internet, you need to use VPC endpoints. Follow the steps described in the AWS docs to do this:
Amazon EC2 instances must be registered as managed instances to be
managed with AWS Systems Manager. Follow these steps:
Verify that SSM Agent is installed on the instance.
Create an AWS Identity and Access Management (IAM) instance profile for Systems Manager. You can create a new role, or add the needed
permissions to an existing role.
Attach the IAM role to your private EC2 instance.
Open the Amazon EC2 console, and then select your instance. On the Description tab, note the VPC ID and Subnet ID.
Create a VPC endpoint for Systems Manager. For Service Name, select com.amazonaws.[region].ssm (for example, com.amazonaws.us-east-1.ssm).
For a full list of Region codes, see Available Regions. For VPC,
choose the VPC ID for your instance. For Subnets, choose a Subnet ID
in your VPC. For high availability, choose at least two subnets from
different Availability Zones within the Region. Note: If you have more
than one subnet in the same Availability Zone, you don't need to
create VPC endpoints for the extra subnets. Any other subnets within
the same Availability Zone can access and use the interface. For
Enable DNS name, select Enable for this endpoint. For more
information, see Private DNS for interface endpoints. For Security
group, select an existing security group, or create a new one. The
security group must allow inbound HTTPS (port 443) traffic from the
resources in your VPC that communicate with the service. If you
created a new security group, open the VPC console, choose Security
Groups, and then select the new security group. On the Inbound rules
tab, choose Edit inbound rules. Add a rule with the following details,
and then choose Save rules: For Type, choose HTTPS. For Source, choose
your VPC CIDR. For advanced configuration, you can allow specific
subnets' CIDR used by your EC2 instances. Note the Security group ID.
You'll use this ID with the other endpoints. Optional: For advanced
setup, create policies for VPC interface endpoints for AWS Systems
Manager. Repeat step 5 with the following change:
For Service Name, select com.amazonaws.[region].ec2messages.
Repeat step 5 with the following change: For Service Name, select com.amazonaws.[region].ssmmessages. You must do this if you want to
use Session Manager.
After the three endpoints are created, your instance appears in
Managed Instances, and can be managed using Systems Manager.

where can I see my own vm and network security group in azure?

Because I have created multiple instances of security group and vm, I forgot what is my network security group and my own VM name. Where can I see my own security group and vm name that is registered at azure?
I can ssh login to the vm instance. Can I see it from there? I need to open a port for connection.
Please copy your vm name when login to the vm instance.
Then nav to azure portal, on the top center -> search box, input your vm name:
Then you can see your vm in the search result:

Cannot connect to PuTTY and WinSCP

I have created a new EC2 instance and installed ftop on it. I am able to access it through PuTTY and WinSCP. Suddenly, once when I try to open through WinSCP, it is giving an error as:
The server rejected SFTP connection, but it listens for FTP
connections. Did you want to use FTP protocol instead of SFTP?
Prefer using encryption.
And through PuTTY it is showing as "CONNECTION REFUSED". I even tried restarting the instance. What is the problem?
If you want to access your Linux EC2 server instance via PuTTY or WinSCP, and you find that you can no longer successfully establish a connection to it, you can do the following in your EC2 AWS Console:
Go to the left panel of your EC2 AWS Console, Network & Security → Security Groups → *<your security group name>
In the Inbound tab, click "Edit".
Go to column "Type", row "SSH".
Go to column "Source" of row "SSH", click the "Custom" dropdown field.
Select "My IP" → Doing this should automatically update your present public IP address setting in AWS.
Take note that your public IP address may change from time to time, depending on your ISP (Internet service provider).
Having said this, whenever it does change, you should be able to resolve this issue by redoing steps 1 - 5.
Make sure the FTP ports that you are trying to access on the machine are enabled by the inbound security group rules.
This answer should help you out further inbound security group.
Also double check to make sure your EC2 machine doesn't have a firewall that may be blocking connections that are allowed by your inbound security policy.
it might be SSH service interrupted. Try to change permissions in the home directory. If the .ssh/ folder permissions changed, you can not connect to the instance. You can try shutdown and then start instead of restart.
If it is not working, please create AMI image of that server, and then try to launch a new instance from that image. Definitely it will work.

How to allow access to ec2 instance service from another set of ec2 machines

I'm using Amazon web service (AWS).
I have a web server installed on one server instance (ec2).
It's served on port 8080. The machine is on a security group called "web-secgrp".
I want to allow access to that web server ONLY from another set of ec2 instances. These instances all share the same security group called "client-secgrp"
I can do this via the security groups by adding each and every individual public IP's of the set of ec2 instances to "web-secgrp". But this is not easy to maintain as I may have more or less of these machines running at once and it's just painful to add all the IP's by hand.
I noticed that in the Source of the security group, I can enter the ID of another security group. I tried entering the ID of client-secgrp in the inbound rules of web-secgroup but that seems to have no effect.
For what it's worth, I also remember that in the (very distant) past, I had to add the security group of an ec2 to the security group rules of an RDS (mysql service).
Any insight on a better way to manage the firewall ports of AWS is greatly appreciated.

Resources