コード例 #1
0
ファイル: Route53.cs プロジェクト: ShowOps/aws-sdk-net
        // Creates a VPC
        private VPC CreateVPC()
        {
            var region = VPCRegion.FindValue(AWSConfigs.RegionEndpoint.SystemName);

            using (var ec2 = new Amazon.EC2.AmazonEC2Client())
            {
                var ec2Vpc = ec2.CreateVpc(new Amazon.EC2.Model.CreateVpcRequest
                {
                    CidrBlock       = "10.0.0.0/16",
                    InstanceTenancy = Amazon.EC2.Tenancy.Default
                }).Vpc;

                return(new VPC
                {
                    VPCRegion = region,
                    VPCId = ec2Vpc.VpcId
                });
            }
        }
コード例 #2
0
        // Creates a VPC
        private VPC CreateVPC()
        {
            var region = VPCRegion.FindValue(ActualEndpoint.SystemName);

            using (var ec2 = TestBase.CreateClient <Amazon.EC2.AmazonEC2Client>())
            {
                var ec2Vpc = ec2.CreateVpcAsync(new Amazon.EC2.Model.CreateVpcRequest
                {
                    CidrBlock       = "10.0.0.0/16",
                    InstanceTenancy = Amazon.EC2.Tenancy.Default
                }).Result.Vpc;

                return(new VPC
                {
                    VPCRegion = region,
                    VPCId = ec2Vpc.VpcId
                });
            }
        }
コード例 #3
0
        /// <summary>
        /// Create a new hosted zone. When you create a zone, its initial status is PENDING. This means that it is not yet available on all DNS servers.
        /// The status of the zone changes to INSYNC when the NS and SOA records are available on all Route 53 DNS servers.
        /// </summary>
        /// <param name="domain">The name of the domain</param>
        /// <param name="vpc">The VPC that you want your hosted zone to be associated with. By providing this parameter, your newly created hosted cannot be resolved anywhere other than the given VPC.</param>
        /// <param name="region">The region of your VPC</param>
        /// <param name="settings">The <see cref="Route53Settings"/> required to connect to Route53.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        public async Task <string> CreateHostedZone(string domain, string vpc, VPCRegion region, Route53Settings settings, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (String.IsNullOrEmpty(domain))
            {
                throw new ArgumentNullException("domain");
            }



            CreateHostedZoneRequest request = new CreateHostedZoneRequest(domain, "");

            if (!String.IsNullOrEmpty(vpc))
            {
                request.VPC = new VPC()
                {
                    VPCId     = vpc,
                    VPCRegion = region
                };
            }

            AmazonRoute53Client      client   = this.GetClient(settings);
            CreateHostedZoneResponse response = await client.CreateHostedZoneAsync(request);

            if (response.HttpStatusCode == HttpStatusCode.OK)
            {
                await this.WaitForChange(client, response.ChangeInfo.Id, 10000, 60);

                _Log.Verbose("Created hosted zone");
                return(response.HostedZone.Id);
            }
            else
            {
                _Log.Error("Could not create hosted zone");
                return("");
            }
        }
コード例 #4
0
 public static async Task <string> CreateHostedZone(this ICakeContext context, string domain, string vpc, VPCRegion region, Route53Settings settings)
 {
     return(await context.CreateManager().CreateHostedZone(domain, vpc, region, settings));
 }