示例#1
0
文件: cfr.go 项目: 2722/lantern
func DisableDistribution(cfr *cloudfront.CloudFront, dist *Distribution) error {
	// See:
	// http://docs.aws.amazon.com/AmazonCloudFront/latest/APIReference/DeleteDistribution.html
	getreq := &cloudfront.GetDistributionConfigRequest{ID: dist.distributionId}
	getresp, err := cfr.GetDistributionConfig(getreq)
	if err != nil {
		return err
	}
	getresp.DistributionConfig.Enabled = aws.False()
	setreq := &cloudfront.UpdateDistributionRequest{
		ID:                 dist.distributionId,
		IfMatch:            getresp.ETag,
		DistributionConfig: getresp.DistributionConfig,
	}
	setresp, err := cfr.UpdateDistribution(setreq)
	if err != nil {
		return err
	}
	if *setresp.Distribution.DistributionConfig.Enabled != false {
		return fmt.Errorf("Attempt to disable distribution had no effect")
	}
	dist.Enabled = false
	dist.Status = "InProgress"
	return nil
}
示例#2
0
文件: cfr.go 项目: 2722/lantern
func DeleteDistribution(cfr *cloudfront.CloudFront, dist *Distribution) error {
	// See:
	// http://docs.aws.amazon.com/AmazonCloudFront/latest/APIReference/DeleteDistribution.html
	getreq := &cloudfront.GetDistributionConfigRequest{ID: dist.distributionId}
	getresp, err := cfr.GetDistributionConfig(getreq)
	if err != nil {
		return err
	}
	delreq := &cloudfront.DeleteDistributionRequest{
		ID:      dist.distributionId,
		IfMatch: getresp.ETag,
	}
	return cfr.DeleteDistribution(delreq)
}