【问题标题】:Creating RDS cloudformation with route 53使用路由 53 创建 RDS cloudformation
【发布时间】:2020-08-28 10:04:03
【问题描述】:

我在使用 aws 云形成时遇到问题。我需要创建 cloudformation,它将使用 RHEL 安装和配置 RDS,使用路由 53 和主用户安装和配置 mariadb。我首先从基本的 config.yaml 开始,但 vpc 出现错误,它说

此用户没有默认 VPC(服务:AmazonEC2;状态代码:400; 错误代码:VPCIdNotSpecified;请求编号: 407bd74c-9b85-4cce-b5a7-b816fe7aea15)

我的 config.yaml 是这个

Resources:
   Ec2Instance1:
      Type: 'AWS::EC2::Instance'
      Properties:
           SecurityGroups:
               - !Ref InstanceSecurityGroup
           KeyName: adivir
           ImageId: ami-07dfba995513840b5
           AvailabilityZone: eu-central-1
           InstanceType: t2.micro
           UserData:
              Fn::Base64: !Sub |
               #!/bin/bash -xe
               yum install -y httpd
               yum install -y git
               yum install -y php php-mysql
               git clone https://github.com/demoglot/php.git /var/www/html
               systemctl restart httpd
               systemctl enable httpd
   Ec2Instance2:
      Type: 'AWS::EC2::Instance'
      Properties:
           SecurityGroups:
               - !Ref InstanceSecurityGroup
           KeyName: adivir
           ImageId: ami-07dfba995513840b5
           AvailabilityZone: eu-central-1
           InstanceType: t2.micro
           UserData:
             Fn::Base64: !Sub |
               #!/bin/bash -xe
               yum install -y httpd
               yum install git -y
               git clone https://github.com/demoglot/php.git /var/www/html
               systemctl restart httpd
               systemctl enable httpd
   InstanceSecurityGroup:
    Type: 'AWS::EC2::SecurityGroup'
    Properties:
      GroupDescription: Enable SSH access
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: '2256'
          ToPort: '2256'
          CidrIp: 0.0.0.0/0

        - IpProtocol: tcp
          FromPort: '80'
          ToPort: '80'
          CidrIp: 0.0.0.0/0
   ElasticLoadBalancer:
    Type: 'AWS::ElasticLoadBalancing::LoadBalancer'
    Properties:
        AvailabilityZones:
             - eu-central-1
             - eu-central-1b
        Listeners:
            - InstancePort: '80'
              LoadBalancerPort: '80'
              Protocol: HTTP
        HealthCheck:
              Target: 'HTTP:80/'
              HealthyThreshold: '3'
              UnhealthyThreshold: '5'
              Interval: '30'
              Timeout: '5'
        Instances :
           - !Ref Ec2Instance1
           - !Ref Ec2Instance2
   DBSECURITYGROUP:
    Type: 'AWS::RDS::DBSecurityGroup'
    Properties:
          GroupDescription: Security Group for RDS private access
          DBSecurityGroupIngress:
            - CIDRIP: 0.0.0.0/0
   MyDB:
    Type: 'AWS::RDS::DBInstance'
    Properties:
        DBName: kk
        AllocatedStorage: '20'
        DBInstanceClass: db.t2.micro
        Engine: MariaDB
        EngineVersion: '10.1.31'
        MasterUsername: admin
        MasterUserPassword: admin123
        DBSecurityGroups:
            - !Ref DBSECURITYGROUP
        Tags:
           - Key: name
             Value: kk
    DeletionPolicy: Snapshot

我需要做什么才能解决 vpc 错误并成功创建 RDS 以及如何以及在 yaml 文件中添加路由 53 创建的位置?此外,数据库需要连接到其他实例上的 java 应用程序。我需要与制作应用程序的人分享什么才能让他连接到数据库?此外,是否可以有一个 shell 脚本按顺序运行 cloudformations,创建堆栈然后退出,这样就不是每个团队成员都需要运行自己的 cloudformation?谢谢

【问题讨论】:

  • 嗨,这似乎是多个问题。第一个问题是您从未指定 VPC id,这意味着默认行为是转到默​​认 VPC。如果没有默认值,则会发生此错误。

标签: amazon-ec2 amazon-cloudformation aws-cloudformation-custom-resource


【解决方案1】:

此问题的解决方案及其发生原因已在最新的 AWS 博客中记录和解释:

基本上,解决方案是创建新的默认 vpc。

附言

我也同意@mokugo-devops。你问了太多的子问题,这限制了你报告的主要问题和问题的重点和准确性。

【讨论】:

  • 啊抱歉,我想一次问所有问题,而不是碰到几个不同的帖子。我让它工作,改变了一些设置,它工作。还添加了路线 53,在文档中找到。
  • @user38974 酷。如果我的回答有用,欢迎采纳。
猜你喜欢
  • 2018-06-24
  • 2018-10-10
  • 1970-01-01
  • 2020-07-01
  • 2020-11-02
  • 2020-02-11
  • 2021-07-21
  • 2014-11-27
  • 1970-01-01
相关资源
最近更新 更多