@104corp/cfn-dns-resolver-module 中文文档教程

发布于 4年前 浏览 21 项目主页 更新于 3年前

CloudFormation DNS Resolver Module

构建状态NPM version

从 CloudFromation 模板

Manage Resources

  • AWS::EC2::SecurityGroup, LaunchTemplate
  • AWS::AutoScaling::AutoScalingGroup, ScalingPolicy
  • AWS::CloudWatch::Alarm
  • AWS::IAM::Role, InstanceProfile
  • AWS::ElasticLoadBalancingV2::LoadBalancer, Listener, TargetGroup
  • AWS::S3::Bucket, BucketPolicy

Install

安装 AWS DNS 解析器实例部署 Node.js 和npm 首先!

npm i @104corp/cfn-dns-resolver-module

Usage

---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'cfn-dns-resolver-module example'
Resources:
  Bucket:
    Type: 'AWS::CloudFormation::Stack'
    Properties:
      Parameters:
        VPCId: 'vpc-26289d41'
        VPCSubnetIds: 'subnet-0a287552, subnet-12560638'
        DNSResovlersSecurityGroupIngressCidr: '172.31.0.0/16'
      TemplateURL: './node_modules/@104corp/cfn-dns-resolver-module/module.yml'
  • Resize Auto Scaling DesiredCapacity
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'cfn-dns-resolver-module example'
Resources:
  Bucket:
    Type: 'AWS::CloudFormation::Stack'
    Properties:
      Parameters:
        VPCId: 'vpc-26289d41'
        VPCSubnetIds: 'subnet-0a287552, subnet-12560638'
        DNSResovlersSecurityGroupIngressCidr: '172.31.0.0/16'
        DNSResovlersAMI: 'ami-023d30a246588ad11'
        AutoScalingInstanceMinSize: "1"
        AutoScalingDesiredCapacity: "1"
      TemplateURL: './node_modules/@104corp/cfn-dns-resolver-module/module.yml'

IAM Policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "devops-infra-cfn-resolver-module",
            "Effect": "Allow",
            "Action": [
                "ec2:TerminateInstances",
                "ec2:DeleteTags",
                "s3:*",
                "ec2:CreateTags",
                "ec2:RunInstances",
                "cloudformation:*",
                "ec2:StopInstances",
                "ec2:Describe*",
                "ec2:StartInstances",
                "ec2:*SecurityGroup*"
            ],
            "Resource": "*"
        }
    ]
}

Package

$ aws cloudformation package --template-file example.yml --s3-bucket <your cfn template bucket> --output-template-file packaged.yml

Deploy

$ aws cloudformation deploy --template-file packaged.yml --stack-name <your stack name>

templates/main

Description

使用混合云时的 AWS 自定义 DNS 解析器。

Parameters

此模板的参数列表:

EnvType

类型:字符串 默认值:开发 说明:此堆栈的环境类型。

StackOwner

类型:字符串 默认值:StackOwnerDefault 说明:所有者

VPCId

类型:AWS::EC2::VPC::Id
说明:(需要)实例的 VPC Id。

VPCSubnetIds

类型:列表
说明:(要求)DNS 解析器的 VPC 子网 ID

DNSResovlersAMI

类型:AWS::EC2::Image::Id
说明:(需要)用于 DNS 解析服务器的自定义 EC2 AMI。

DNSResovlersSecurityGroupIngressCidr

类型:字符串 默认值:0.0.0.0/0 说明:(需要)入口安全组的 VPC CIDR。

AutoScalingOutPolicyHighCPU

类型:字符串 默认值:80 说明:(可选)需要多少百分比的 cpu 使用率来扩展实例,默认是 80%。

AutoScalingInPolicyLowCPU

类型:字符串 默认值:30 说明:(可选)缩减实例需要多少百分比的 cpu 使用率,默认为 30%。

AutoScalingLaunchTemplateDefaultVersion

类型:字符串 默认值:1 说明:(可选)自动缩放组的启动模板默认版本,默认为 1。

AutoScalingInstanceMinSize

类型:字符串 默认值:2 说明:(可选)最小实例容量,默认为2。

AutoScalingInstanceMaxSize

类型:String 默认值:4 说明:(可选)最大实例容量,默认为4。

AutoScalingDesiredCapacity

类型:String 默认值:2 说明:(可选)最大实例容量,默认为2。

DNSResovlersInstanceType

类型:String 默认值:t3.nano 说明:(可选)DNS 解析服务器的 EC2 实例类型。 默认 t3.nano

NlbAccessLogExpirationDays

类型:字符串 默认值:30 说明:(可选)NLB 访问日志生命周期到期天数。 默认 30

Resources

此模板创建的资源列表:

DNSResolverInstanceSG

类型:AWS::EC2::SecurityGroup

DnsResolverLaunchTemplate

类型:AWS::EC2::LaunchTemplate

DnsResolverASGroup

类型:AWS::AutoScaling::AutoScalingGroup

DnsResolverScaleOutPolicy

类型:AWS::AutoScaling ::ScalingPolicy

DnsResolverScaleInPolicy

类型:AWS::AutoScaling::ScalingPolicy

DnsResolverCPUAlarmHigh

类型:AWS::CloudWatch::Alarm

DnsResolverCPUAlarmLow

类型:AWS::CloudWatch::Alarm

DnsResolverRole

类型:AWS::IAM::Role

DnsResolverInstanceProfile

类型:AWS::IAM::InstanceProfile

DNSResolverNlb

类型: AWS::ElasticLoadBalancingV2::LoadBalancer

DNSResolverNlbListener

类型:AWS::ElasticLoadBalancingV2::Listener

DNSResolverNlbTargetGroup

类型:AWS::ElasticLoadBalancingV2::TargetGroup

ResolverNlbLogS3Bucket

类型:AWS::S3::Bucket

S3BucketPolicy

类型:AWS::S3::BucketPolicy

Outputs

此模板公开的输出列表:

Maintenance

维护者:

  • 104corp

CloudFormation DNS Resolver Module

Build StatusNPM version

AWS DNS Resolver Instance deployment from CloudFromation Template

Manage Resources

  • AWS::EC2::SecurityGroup, LaunchTemplate
  • AWS::AutoScaling::AutoScalingGroup, ScalingPolicy
  • AWS::CloudWatch::Alarm
  • AWS::IAM::Role, InstanceProfile
  • AWS::ElasticLoadBalancingV2::LoadBalancer, Listener, TargetGroup
  • AWS::S3::Bucket, BucketPolicy

Install

Install Node.js and npm first!

npm i @104corp/cfn-dns-resolver-module

Usage

---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'cfn-dns-resolver-module example'
Resources:
  Bucket:
    Type: 'AWS::CloudFormation::Stack'
    Properties:
      Parameters:
        VPCId: 'vpc-26289d41'
        VPCSubnetIds: 'subnet-0a287552, subnet-12560638'
        DNSResovlersSecurityGroupIngressCidr: '172.31.0.0/16'
      TemplateURL: './node_modules/@104corp/cfn-dns-resolver-module/module.yml'
  • Resize Auto Scaling DesiredCapacity
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'cfn-dns-resolver-module example'
Resources:
  Bucket:
    Type: 'AWS::CloudFormation::Stack'
    Properties:
      Parameters:
        VPCId: 'vpc-26289d41'
        VPCSubnetIds: 'subnet-0a287552, subnet-12560638'
        DNSResovlersSecurityGroupIngressCidr: '172.31.0.0/16'
        DNSResovlersAMI: 'ami-023d30a246588ad11'
        AutoScalingInstanceMinSize: "1"
        AutoScalingDesiredCapacity: "1"
      TemplateURL: './node_modules/@104corp/cfn-dns-resolver-module/module.yml'

IAM Policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "devops-infra-cfn-resolver-module",
            "Effect": "Allow",
            "Action": [
                "ec2:TerminateInstances",
                "ec2:DeleteTags",
                "s3:*",
                "ec2:CreateTags",
                "ec2:RunInstances",
                "cloudformation:*",
                "ec2:StopInstances",
                "ec2:Describe*",
                "ec2:StartInstances",
                "ec2:*SecurityGroup*"
            ],
            "Resource": "*"
        }
    ]
}

Package

$ aws cloudformation package --template-file example.yml --s3-bucket <your cfn template bucket> --output-template-file packaged.yml

Deploy

$ aws cloudformation deploy --template-file packaged.yml --stack-name <your stack name>

templates/main

Description

AWS custom DNS Resolver when use Hybrid Cloud.

Parameters

The list of parameters for this template:

EnvType

Type: String Default: Dev Description: Environment Type for this Stack.

StackOwner

Type: String Default: StackOwnerDefault Description: Owner

VPCId

Type: AWS::EC2::VPC::Id
Description: (Require) VPC Id for instances.

VPCSubnetIds

Type: List
Description: (Require) VPC Subnet Id for DNS Resolver

DNSResovlersAMI

Type: AWS::EC2::Image::Id
Description: (Require) Custom EC2 AMI for DNS Resolver Servers.

DNSResovlersSecurityGroupIngressCidr

Type: String Default: 0.0.0.0/0 Description: (Require) VPC CIDR for ingress security group.

AutoScalingOutPolicyHighCPU

Type: String Default: 80 Description: (Optional) How many percent cpu usage need to scaling up instance, default is 80 percent.

AutoScalingInPolicyLowCPU

Type: String Default: 30 Description: (Optional) How many percent cpu usage need to scaling down instance, default is 30 percent.

AutoScalingLaunchTemplateDefaultVersion

Type: String Default: 1 Description: (Optional) Launch template default version for Autoscaling Group, default is 1.

AutoScalingInstanceMinSize

Type: String Default: 2 Description: (Optional) minimum instance capacity, default is 2.

AutoScalingInstanceMaxSize

Type: String Default: 4 Description: (Optional) maximum instance capacity, default is 4.

AutoScalingDesiredCapacity

Type: String Default: 2 Description: (Optional) maximum instance capacity, default is 2.

DNSResovlersInstanceType

Type: String Default: t3.nano Description: (Optional) EC2 instances type for DNS Resolver Servers. default t3.nano

NlbAccessLogExpirationDays

Type: String Default: 30 Description: (Optional) NLB access log Lifecycle expiration days. default 30

Resources

The list of resources this template creates:

DNSResolverInstanceSG

Type: AWS::EC2::SecurityGroup

DnsResolverLaunchTemplate

Type: AWS::EC2::LaunchTemplate

DnsResolverASGroup

Type: AWS::AutoScaling::AutoScalingGroup

DnsResolverScaleOutPolicy

Type: AWS::AutoScaling::ScalingPolicy

DnsResolverScaleInPolicy

Type: AWS::AutoScaling::ScalingPolicy

DnsResolverCPUAlarmHigh

Type: AWS::CloudWatch::Alarm

DnsResolverCPUAlarmLow

Type: AWS::CloudWatch::Alarm

DnsResolverRole

Type: AWS::IAM::Role

DnsResolverInstanceProfile

Type: AWS::IAM::InstanceProfile

DNSResolverNlb

Type: AWS::ElasticLoadBalancingV2::LoadBalancer

DNSResolverNlbListener

Type: AWS::ElasticLoadBalancingV2::Listener

DNSResolverNlbTargetGroup

Type: AWS::ElasticLoadBalancingV2::TargetGroup

ResolverNlbLogS3Bucket

Type: AWS::S3::Bucket

S3BucketPolicy

Type: AWS::S3::BucketPolicy

Outputs

The list of outputs this template exposes:

Maintenance

Maintainers:

  • 104corp
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文