How can I use the boto3 library to whitelist VPC IP addresses? For example, if I want to whitelist traffic from an IP address 12.345.678.90
to a Postgres RDS instance running within a VPC on port 5432.
Here's a sample way to whitelist traffic for an IP address that will connect to traffic on port 5432:
import boto3
ec2 = new_session.client('ec2', region_name='us-east-1')
ec2.authorize_security_group_ingress(
GroupId='sg-123456',
IpPermissions=[
{
'IpProtocol': 'tcp',
'IpRanges': [
{ 'CidrIp': '12.345.678.90/32', 'Description': 'Test allowing ingress' }
],
'FromPort': 5432,
'ToPort': 5432,}
],
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.