예제 #1
0
        internal ChangeTagsForResourceResponse ChangeTagsForResource(ChangeTagsForResourceRequest request)
        {
            var marshaller   = new ChangeTagsForResourceRequestMarshaller();
            var unmarshaller = ChangeTagsForResourceResponseUnmarshaller.Instance;

            return(Invoke <ChangeTagsForResourceRequest, ChangeTagsForResourceResponse>(request, marshaller, unmarshaller));
        }
예제 #2
0
        /// <summary>
        /// Initiates the asynchronous execution of the ChangeTagsForResource operation.
        /// <seealso cref="Amazon.Route53.IAmazonRoute53"/>
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the ChangeTagsForResource operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task <ChangeTagsForResourceResponse> ChangeTagsForResourceAsync(ChangeTagsForResourceRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new ChangeTagsForResourceRequestMarshaller();
            var unmarshaller = ChangeTagsForResourceResponseUnmarshaller.Instance;

            return(InvokeAsync <ChangeTagsForResourceRequest, ChangeTagsForResourceResponse>(request, marshaller,
                                                                                             unmarshaller, cancellationToken));
        }
예제 #3
0
 public virtual Task <ChangeTagsForResourceResponse> ChangeTagsForResourceAsync(ChangeTagsForResourceRequest request, CancellationToken cancellationToken = default(CancellationToken))
 {
     throw new NotImplementedException();
 }
예제 #4
0
파일: R53Trigger.cs 프로젝트: zyborg/VMBot
        public async Task HandleInitR53(Instance inst, Dictionary <string, string> tags, string ec2State)
        {
            _logger.LogInformation("Handling CREATING R53 records");

            var r53Spec    = ResolveR53RecordSpec(inst, tags);
            var r53Routing = ResolveR53RoutingSpec(inst, tags);
            var r53Health  = await ResolveR53HealthCheckSpec(inst, tags);

            HealthCheck existingHealth = await FindExistingHealthCheck(r53Health);

            // We apply the Health Check if any, first because
            // the subsequent Route policy may depend on it
            string healthCheckId = null;

            if (r53Health != null)
            {
                if (existingHealth == null)
                {
                    var createRequ = new CreateHealthCheckRequest
                    {
                        CallerReference   = r53Health.RefName,
                        HealthCheckConfig = r53Health.Config,
                    };
                    var createResp = await _r53.CreateHealthCheckAsync(createRequ);

                    _logger.LogInformation("CREATE Health Check request completed, response:");
                    _logger.LogInformation(JsonSerializer.Serialize(createResp));
                    if (createResp.HealthCheck == null)
                    {
                        throw new Exception("failed to create Health Check");
                    }
                    healthCheckId = createResp.HealthCheck.Id;

                    var tagRequ = new ChangeTagsForResourceRequest
                    {
                        ResourceType = TagResourceType.Healthcheck,
                        ResourceId   = healthCheckId,
                        AddTags      = new List <Amazon.Route53.Model.Tag>
                        {
                            new Amazon.Route53.Model.Tag
                            {
                                Key   = "Name",
                                Value = r53Health.RefName,
                            },
                            new Amazon.Route53.Model.Tag
                            {
                                Key   = "vmbot:memo",
                                Value = $"Managed by VMBot {nameof(R53Trigger)}",
                            },
                        },
                    };
                    var tagResp = await _r53.ChangeTagsForResourceAsync(tagRequ);

                    _logger.LogInformation("CHANGED TAGS for Health Check:");
                    _logger.LogInformation(JsonSerializer.Serialize(tagResp));
                }
                else
                {
                    var updateRequ = new UpdateHealthCheckRequest
                    {
                        HealthCheckId      = existingHealth.Id,
                        HealthCheckVersion = existingHealth.HealthCheckVersion,
                    };
                    CopyOrReset(existingHealth.HealthCheckConfig, r53Health.Config, updateRequ);
                    _logger.LogInformation("Resolved Health Check delta:");
                    _logger.LogInformation(JsonSerializer.Serialize(updateRequ));
                    var updateResp = await _r53.UpdateHealthCheckAsync(updateRequ);

                    _logger.LogInformation("UPDATE Health Check request completed, response:");
                    _logger.LogInformation(JsonSerializer.Serialize(updateResp));
                    healthCheckId = updateResp.HealthCheck.Id;
                }
            }

            if (r53Spec != null)
            {
                var rrset = new ResourceRecordSet
                {
                    Name            = r53Spec.Name,
                    Type            = RRType.FindValue(r53Spec.Type),
                    TTL             = r53Spec.TTL,
                    ResourceRecords = new List <ResourceRecord>
                    {
                        new ResourceRecord(r53Spec.Value),
                    },
                };
                if (healthCheckId != null)
                {
                    rrset.HealthCheckId = healthCheckId;
                }

                // Optional routing policy configuration
                r53Routing?.Apply(rrset);

                var changeRequ = new ChangeResourceRecordSetsRequest
                {
                    HostedZoneId = r53Spec.Zone,
                    ChangeBatch  = new ChangeBatch
                    {
                        Changes = new List <Change>
                        {
                            new Change
                            {
                                Action            = ChangeAction.UPSERT,
                                ResourceRecordSet = rrset,
                            }
                        },
                        Comment = "change request applied by VMBot",
                    }
                };

                var changeResp = await _r53.ChangeResourceRecordSetsAsync(changeRequ);

                _logger.LogInformation("UPSERT Resource Record request completed, response:");
                _logger.LogInformation(JsonSerializer.Serialize(changeResp));
            }
        }