简体   繁体   English

如何使用 CDK 将 AWS ECS (ApplicationLoadBalancedFargateService) 私有 IP 连接到 RDS 安全组

[英]How to Connect AWS ECS (ApplicationLoadBalancedFargateService) Private IP to RDS Security Group Using CDK

How to Connect ECS Private IP to RDS Security Group Using CDK?如何使用 CDK 将 ECS 私有 IP 连接到 RDS 安全组?

I need a private ip of ApplicationLoadBalancedFargateService (CDK Code).我需要 ApplicationLoadBalancedFargateService(CDK 代码)的私有 ip。

I tried the following (Failed to resolve) :我尝试了以下(无法解决):

    const auroraSecurityGroup = new ec2.SecurityGroup(this, 'security-group', {
      vpc,
      allowAllOutbound: true,
      description: 'Security Group of Aurora PostgreSQL',
      securityGroupName: AURORA_SECURITY_GROUP_NAME
    });

    auroraSecurityGroup.addIngressRule(ec2.Peer.ipv4('my ecs private ip'), ec2.Port.tcp(DB_PORT), 'describe');

If you would like to allow specific ip address, you have to specify with cidr.如果你想允许特定的 ip 地址,你必须用 cidr 指定。

ec2.Peer.ipv4('1.2.3.4/32')

Allow the security group of the fargate service as a source to arurora seucirty group:允许 fargate 服务的安全组作为源到 arurora seucirty 组:

auroraSecurityGroup.connections.allowFrom(ecsService.service, Port.tcp(3306), 'Inbound');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 允许使用 AWS CDK 从一个安全组进入另一个安全组 - Allow ingress from one security group to another using AWS CDK 如何使用 TypeScript 在 AWS CDK 中的 VPC 中导入现有私有子网? - How to import existing private subnets in a VPC in AWS CDK using TypeScript? 使用CDK时如何将服务的安全组设置为默认安全组 - How do I set the the security group of a service to the default security group when using CDK 如何使用 CDK 在 Postgres RDS 中创建表? - How to create tables in Postgres RDS using CDK? 如何在nodejs项目中获取aws ecs容器ip地址 - How to fetch aws ecs container ip address in nodejs project 如何让 CDK 仅创建一个弹性 IP 地址以用于单个 EC2 实例 (AWS CDK) - How to have the CDK create only one Elastic IP address for use with a single EC2 instance (AWS CDK) 如何使用aws cdk管理多个环境? - How to manage multiple environments using aws cdk? 解决了|| 使用 AWS-CDK Typescript 更新单个堆栈时出现 RDS 堆栈问题 - SOLVED || Issue with RDS stack when updating a single stack using AWS-CDK Typescript 如何将CDK映像资产部署到ECS集群 - How to deploy cdk image asset to ecs cluster CDK中如何给其他安全组添加安全组ID? - How do you add security group ID to other security group in CDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM