diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-03-13 16:43:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-13 16:43:00 -0400 |
commit | 24496cd0b278352b44e9411d924185e306fa346b (patch) | |
tree | 171f670e432b02309d0963fae811aec079fc128e /vendor/github.com/goamz/goamz/cloudformation | |
parent | 3b081bda080eceeb05c63e74cf2803821f1330ab (diff) | |
download | chat-24496cd0b278352b44e9411d924185e306fa346b.tar.gz chat-24496cd0b278352b44e9411d924185e306fa346b.tar.bz2 chat-24496cd0b278352b44e9411d924185e306fa346b.zip |
Removing goamz (#5753)
Diffstat (limited to 'vendor/github.com/goamz/goamz/cloudformation')
3 files changed, 0 insertions, 1861 deletions
diff --git a/vendor/github.com/goamz/goamz/cloudformation/cloudformation.go b/vendor/github.com/goamz/goamz/cloudformation/cloudformation.go deleted file mode 100644 index 00081d0c2..000000000 --- a/vendor/github.com/goamz/goamz/cloudformation/cloudformation.go +++ /dev/null @@ -1,837 +0,0 @@ -// -// cloudformation: This package provides types and functions to interact with the AWS CloudFormation API -// -// Depends on https://github.com/goamz/goamz -// - -package cloudformation - -import ( - "encoding/xml" - "fmt" - "log" - "net/http" - "net/http/httputil" - "net/url" - "strconv" - "strings" - "time" - - "github.com/goamz/goamz/aws" -) - -// The CloudFormation type encapsulates operations within a specific EC2 region. -type CloudFormation struct { - aws.Auth - aws.Region -} - -// New creates a new CloudFormation Client. -func New(auth aws.Auth, region aws.Region) *CloudFormation { - - return &CloudFormation{auth, region} - -} - -const debug = false - -// ---------------------------------------------------------------------------- -// Request dispatching logic. - -// Error encapsulates an error returned by the AWS CloudFormation API. -// -// See http://goo.gl/zDZbuQ for more details. -type Error struct { - // HTTP status code (200, 403, ...) - StatusCode int - // Error type - Type string `xml:"Type"` - // CloudFormation error code - Code string `xml:"Code"` - // The human-oriented error message - Message string `xml:"Message"` - RequestId string `xml:"RequestID"` -} - -func (err *Error) Error() string { - if err.Code == "" { - return err.Message - } - - return fmt.Sprintf("%s (%s)", err.Message, err.Code) -} - -type xmlErrors struct { - RequestId string `xml:"RequestId"` - Errors []Error `xml:"Error"` -} - -func (c *CloudFormation) query(params map[string]string, resp interface{}) error { - params["Version"] = "2010-05-15" - - data := strings.NewReader(multimap(params).Encode()) - - hreq, err := http.NewRequest("POST", c.Region.CloudFormationEndpoint+"/", data) - if err != nil { - return err - } - - hreq.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value") - - token := c.Auth.Token() - if token != "" { - hreq.Header.Set("X-Amz-Security-Token", token) - } - - signer := aws.NewV4Signer(c.Auth, "cloudformation", c.Region) - signer.Sign(hreq) - - if debug { - log.Printf("%v -> {\n", hreq) - } - r, err := http.DefaultClient.Do(hreq) - - if err != nil { - log.Printf("Error calling Amazon") - return err - } - - defer r.Body.Close() - - if debug { - dump, _ := httputil.DumpResponse(r, true) - log.Printf("response:\n") - log.Printf("%v\n}\n", string(dump)) - } - if r.StatusCode != 200 { - return buildError(r) - } - err = xml.NewDecoder(r.Body).Decode(resp) - return err -} - -func buildError(r *http.Response) error { - var ( - err Error - errors xmlErrors - ) - xml.NewDecoder(r.Body).Decode(&errors) - if len(errors.Errors) > 0 { - err = errors.Errors[0] - } - - err.RequestId = errors.RequestId - err.StatusCode = r.StatusCode - if err.Message == "" { - err.Message = r.Status - } - return &err -} - -func makeParams(action string) map[string]string { - params := make(map[string]string) - params["Action"] = action - return params -} - -func multimap(p map[string]string) url.Values { - q := make(url.Values, len(p)) - for k, v := range p { - q[k] = []string{v} - } - return q -} - -// addParamsList adds params in the form of param.member.N to the params map -func addParamsList(params map[string]string, label string, ids []string) { - for i, id := range ids { - params[label+"."+strconv.Itoa(i+1)] = id - } -} - -// ----------------------------------------------------------------------- -// API Supported Types and Methods - -// SimpleResp is the basic response from most actions. -type SimpleResp struct { - XMLName xml.Name - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// CancelUpdateStack cancels an update on the specified stack. -// If the call completes successfully, the stack will roll back the update and revert -// to the previous stack configuration. -// -// See http://goo.gl/ZE6fOa for more details -func (c *CloudFormation) CancelUpdateStack(stackName string) (resp *SimpleResp, err error) { - params := makeParams("CancelUpdateStack") - - params["StackName"] = stackName - - resp = new(SimpleResp) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Parameter encapsulates the cloudstack paramter data type -// -// See http://goo.gl/2rg9eG for more details -type Parameter struct { - ParameterKey string `xml:"ParameterKey"` - ParameterValue string `xml:"ParameterValue"` - UsePreviousValue bool `xml:"UsePreviousValue"` -} - -type Tag struct { - Key string `xml:"Key"` - Value string `xml:"Value"` -} - -// CreateStackParams wraps CreateStack request options -// -// See http://goo.gl/yDZYuV for more information -type CreateStackParams struct { - Capabilities []string - DisableRollback bool - NotificationARNs []string - OnFailure string - Parameters []Parameter - StackName string - StackPolicyBody string - StackPolicyURL string - Tags []Tag - TemplateBody string - TemplateURL string - TimeoutInMinutes int -} - -// CreateStackResponse wraps a CreateStack call response -// -// See http://goo.gl/yDZYuV for more details -type CreateStackResponse struct { - StackId string `xml:"CreateStackResult>StackId"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// CreateStack creates a stack as specified in the template. After the call completes successfully, -// the stack creation starts. -// -// Required params: StackName -// -// See http://goo.gl/yDZYuV for more details -func (c *CloudFormation) CreateStack(options *CreateStackParams) ( - resp *CreateStackResponse, err error) { - params := makeParams("CreateStack") - - params["StackName"] = options.StackName - - if options.DisableRollback { - params["DisableRollback"] = strconv.FormatBool(options.DisableRollback) - } - if options.OnFailure != "" { - params["OnFailure"] = options.OnFailure - } - if options.StackPolicyBody != "" { - params["StackPolicyBody"] = options.StackPolicyBody - } - if options.StackPolicyURL != "" { - params["StackPolicyURL"] = options.StackPolicyURL - } - if options.TemplateBody != "" { - params["TemplateBody"] = options.TemplateBody - } - if options.TemplateURL != "" { - params["TemplateURL"] = options.TemplateURL - } - if options.TimeoutInMinutes != 0 { - params["TimeoutInMinutes"] = strconv.Itoa(options.TimeoutInMinutes) - } - if len(options.Capabilities) > 0 { - addParamsList(params, "Capabilities.member", options.Capabilities) - } - if len(options.NotificationARNs) > 0 { - addParamsList(params, "NotificationARNs.member", options.NotificationARNs) - } - // Add any parameters - for i, t := range options.Parameters { - key := "Parameters.member.%d.%s" - index := i + 1 - params[fmt.Sprintf(key, index, "ParameterKey")] = t.ParameterKey - params[fmt.Sprintf(key, index, "ParameterValue")] = t.ParameterValue - params[fmt.Sprintf(key, index, "UsePreviousValue")] = strconv.FormatBool(t.UsePreviousValue) - } - // Add any tags - for i, t := range options.Tags { - key := "Tags.member.%d.%s" - index := i + 1 - params[fmt.Sprintf(key, index, "Key")] = t.Key - params[fmt.Sprintf(key, index, "Value")] = t.Value - } - - resp = new(CreateStackResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// DeleteStack deletes a specified stack. -// Once the call completes successfully, stack deletion starts. -// -// See http://goo.gl/CVMpxC for more details -func (c *CloudFormation) DeleteStack(stackName string) (resp *SimpleResp, err error) { - params := makeParams("DeleteStack") - - params["StackName"] = stackName - - resp = new(SimpleResp) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// StackEvent encapsulates the StackEvent data type -// -// See http://goo.gl/EHwiMf for more details -type StackEvent struct { - EventId string `xml:"EventId"` - LogicalResourceId string `xml:"LogicalResourceId"` - PhysicalResourceId string `xml:"PhysicalResourceId"` - ResourceProperties string `xml:"ResourceProperties"` - ResourceStatus string `xml:"ResourceStatus"` - ResourceStatusReason string `xml:"ResourceStatusReason"` - ResourceType string `xml:"ResourceType"` - StackId string `xml:"StackId"` - StackName string `xml:"StackName"` - Timestamp time.Time `xml:"Timestamp"` -} - -// DescribeStackEventsResponse wraps a response returned by DescribeStackEvents request -// -// See http://goo.gl/zqj4Bz for more details -type DescribeStackEventsResponse struct { - NextToken string `xml:"DescribeStackEventsResult>NextToken"` - StackEvents []StackEvent `xml:"DescribeStackEventsResult>StackEvents>member"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// DescribeStackEvents returns all stack related events for a specified stack. -// -// See http://goo.gl/zqj4Bz for more details -func (c *CloudFormation) DescribeStackEvents(stackName string, nextToken string) ( - resp *DescribeStackEventsResponse, err error) { - params := makeParams("DescribeStackEvents") - - if stackName != "" { - params["StackName"] = stackName - } - if nextToken != "" { - params["NextToken"] = nextToken - } - - resp = new(DescribeStackEventsResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// StackResourceDetail encapsulates the StackResourceDetail data type -// -// See http://goo.gl/flce6I for more details -type StackResourceDetail struct { - Description string `xml:"Description"` - LastUpdatedTimestamp time.Time `xml:"LastUpdatedTimestamp"` - LogicalResourceId string `xml:"LogicalResourceId"` - Metadata string `xml:"Metadata"` - PhysicalResourceId string `xml:"PhysicalResourceId"` - ResourceStatus string `xml:"ResourceStatus"` - ResourceStatusReason string `xml:"ResourceStatusReason"` - ResourceType string `xml:"ResourceType"` - StackId string `xml:"StackId"` - StackName string `xml:"StackName"` -} - -// DescribeStackResourceResponse wraps a response returned by DescribeStackResource request -// -// See http://goo.gl/6pfPFs for more details -type DescribeStackResourceResponse struct { - StackResourceDetail StackResourceDetail `xml:"DescribeStackResourceResult>StackResourceDetail"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// DescribeStackResource returns a description of the specified resource in the specified stack. -// For deleted stacks, DescribeStackResource returns resource information -// for up to 90 days after the stack has been deleted. -// -// Required params: stackName, logicalResourceId -// -// See http://goo.gl/6pfPFs for more details -func (c *CloudFormation) DescribeStackResource(stackName string, logicalResourceId string) ( - resp *DescribeStackResourceResponse, err error) { - params := makeParams("DescribeStackResource") - - params["StackName"] = stackName - params["LogicalResourceId"] = logicalResourceId - - resp = new(DescribeStackResourceResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// StackResource encapsulates the StackResource data type -// -// See http://goo.gl/j4eli5 for more details -type StackResource struct { - Description string `xml:"Description"` - LogicalResourceId string `xml:"LogicalResourceId"` - PhysicalResourceId string `xml:"PhysicalResourceId"` - ResourceStatus string `xml:"ResourceStatus"` - ResourceStatusReason string `xml:"ResourceStatusReason"` - ResourceType string `xml:"ResourceType"` - StackId string `xml:"StackId"` - StackName string `xml:"StackName"` - Timestamp time.Time `xml:"Timestamp"` -} - -// DescribeStackResourcesResponse wraps a response returned by DescribeStackResources request -// -// See http://goo.gl/YnY5rs for more details -type DescribeStackResourcesResponse struct { - StackResources []StackResource `xml:"DescribeStackResourcesResult>StackResources>member"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// DescribeStackResources returns AWS resource descriptions for running and deleted stacks. -// If stackName is specified, all the associated resources that are part of the stack are returned. -// If physicalResourceId is specified, the associated resources of the stack that the resource -// belongs to are returned. -// -// Only the first 100 resources will be returned. If your stack has more resources than this, -// you should use ListStackResources instead. -// -// See http://goo.gl/YnY5rs for more details -func (c *CloudFormation) DescribeStackResources(stackName, physicalResourceId, logicalResourceId string) ( - resp *DescribeStackResourcesResponse, err error) { - params := makeParams("DescribeStackResources") - - if stackName != "" { - params["StackName"] = stackName - } - if physicalResourceId != "" { - params["PhysicalResourceId"] = physicalResourceId - } - if logicalResourceId != "" { - params["LogicalResourceId"] = logicalResourceId - } - - resp = new(DescribeStackResourcesResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// Output encapsulates the Output AWS data type -// -// See http://goo.gl/UOn7q6 for more information -type Output struct { - Description string `xml:"Description"` - OutputKey string `xml:"OutputKey"` - OutputValue string `xml:"OutputValue"` -} - -// Stack encapsulates the Stack AWS data type -// -// See http://goo.gl/yDZYuV for more information -type Stack struct { - Capabilities []string `xml:"Capabilities>member"` - CreationTime time.Time `xml:"CreationTime"` - Description string `xml:"Description"` - DisableRollback bool `xml:"DisableRollback"` - LastUpdatedTime time.Time `xml:"LastUpdatedTime"` - NotificationARNs []string `xml:"NotificationARNs>member"` - Outputs []Output `xml:"Outputs>member"` - Parameters []Parameter `xml:"Parameters>member"` - StackId string `xml:"StackId"` - StackName string `xml:"StackName"` - StackStatus string `xml:"StackStatus"` - StackStatusReason string `xml:"StackStatusReason"` - Tags []Tag `xml:"Tags>member"` - TimeoutInMinutes int `xml:"TimeoutInMinutes"` -} - -// DescribeStacksResponse wraps a response returned by DescribeStacks request -// -// See http://goo.gl/UOLsXD for more information -type DescribeStacksResponse struct { - NextToken string `xml:"DescribeStacksResult>NextToken"` - Stacks []Stack `xml:"DescribeStacksResult>Stacks>member"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// DescribeStacks returns the description for the specified stack; -// If no stack name was specified, then it returns the description for all the stacks created. -// -// See http://goo.gl/UOLsXD for more information -func (c *CloudFormation) DescribeStacks(stackName string, nextToken string) ( - resp *DescribeStacksResponse, err error) { - params := makeParams("DescribeStacks") - - if stackName != "" { - params["StackName"] = stackName - } - if nextToken != "" { - params["NextToken"] = nextToken - } - - resp = new(DescribeStacksResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// EstimateTemplateCostResponse wraps a response returned by EstimateTemplateCost request -// -// See http://goo.gl/PD9hle for more information -type EstimateTemplateCostResponse struct { - Url string `xml:"EstimateTemplateCostResult>Url"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// EstimateTemplateCost returns the estimated monthly cost of a template. -// The return value is an AWS Simple Monthly Calculator URL with a query string that describes -// the resources required to run the template. -// -// See http://goo.gl/PD9hle for more information -func (c *CloudFormation) EstimateTemplateCost(parameters []Parameter, templateBody, templateUrl string) ( - resp *EstimateTemplateCostResponse, err error) { - params := makeParams("EstimateTemplateCost") - - if templateBody != "" { - params["TemplateBody"] = templateBody - } - if templateUrl != "" { - params["TemplateURL"] = templateUrl - } - // Add any parameters - for i, t := range parameters { - key := "Parameters.member.%d.%s" - index := i + 1 - params[fmt.Sprintf(key, index, "ParameterKey")] = t.ParameterKey - params[fmt.Sprintf(key, index, "ParameterValue")] = t.ParameterValue - params[fmt.Sprintf(key, index, "UsePreviousValue")] = strconv.FormatBool(t.UsePreviousValue) - } - - resp = new(EstimateTemplateCostResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// GetStackPolicyResponse wraps a response returned by GetStackPolicy request -// -// See http://goo.gl/iZFSgy for more information -type GetStackPolicyResponse struct { - StackPolicyBody string `xml:"GetStackPolicyResult>StackPolicyBody"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// GetStackPolicy returns the stack policy for a specified stack. If a stack doesn't have a policy, -// a null value is returned. -// -// See http://goo.gl/iZFSgy for more information -func (c *CloudFormation) GetStackPolicy(stackName string) ( - resp *GetStackPolicyResponse, err error) { - params := makeParams("GetStackPolicy") - - params["StackName"] = stackName - - resp = new(GetStackPolicyResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// GetTemplateResponse wraps a response returned by GetTemplate request -// -// See http://goo.gl/GU59CB for more information -type GetTemplateResponse struct { - TemplateBody string `xml:"GetTemplateResult>TemplateBody"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// GetTemplate returns the template body for a specified stack. -// You can get the template for running or deleted stacks -// -// Required Params: StackName - The name or the unique identifier associated with the stack, -// which are not always interchangeable: -// Running stacks: You can specify either the stack's name or its unique stack ID. -// Deleted stacks: You must specify the unique stack ID. -// -// See http://goo.gl/GU59CB for more information -func (c *CloudFormation) GetTemplate(stackName string) ( - resp *GetTemplateResponse, err error) { - params := makeParams("GetTemplate") - - params["StackName"] = stackName - - resp = new(GetTemplateResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// StackResourceSummary encapsulates the StackResourceSummary data type -// -// See http://goo.gl/Af0vcm for more details -type StackResourceSummary struct { - LastUpdatedTimestamp time.Time `xml:"LastUpdatedTimestamp"` - LogicalResourceId string `xml:"LogicalResourceId"` - PhysicalResourceId string `xml:"PhysicalResourceId"` - ResourceStatus string `xml:"ResourceStatus"` - ResourceStatusReason string `xml:"ResourceStatusReason"` - ResourceType string `xml:"ResourceType"` -} - -// ListStackResourcesResponse wraps a response returned by ListStackResources request -// -// See http://goo.gl/JUCgLf for more details -type ListStackResourcesResponse struct { - NextToken string `xml:"ListStackResourcesResult>NextToken"` - StackResourceSummaries []StackResourceSummary `xml:"ListStackResourcesResult>StackResourceSummaries>member"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// ListStackResources returns descriptions of all resources of the specified stack. -// For deleted stacks, ListStackResources returns resource information for up to 90 days -// after the stack has been deleted. -// -// Required Params: stackName - the name or the unique identifier associated with the stack, -// which are not always interchangeable: -// Running stacks: You can specify either the stack's name or its unique stack ID. -// Deleted stacks: You must specify the unique stack ID. -// -// See http://goo.gl/JUCgLf for more details -func (c *CloudFormation) ListStackResources(stackName, nextToken string) ( - resp *ListStackResourcesResponse, err error) { - params := makeParams("ListStackResources") - - params["StackName"] = stackName - - if nextToken != "" { - params["NextToken"] = nextToken - } - - resp = new(ListStackResourcesResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// StackSummary encapsulates the StackSummary data type -// -// See http://goo.gl/35j3wf for more details -type StackSummary struct { - CreationTime time.Time `xml:"CreationTime"` - DeletionTime time.Time `xml:"DeletionTime"` - LastUpdatedTime time.Time `xml:"LastUpdatedTime"` - StackId string `xml:"StackId"` - StackName string `xml:"StackName"` - StackStatus string `xml:"StackStatus"` - StackStatusReason string `xml:"StackStatusReason"` - TemplateDescription string `xml:"TemplateDescription"` -} - -// ListStacksResponse wraps a response returned by ListStacks request -// -// See http://goo.gl/UWi6nm for more details -type ListStacksResponse struct { - NextToken string `xml:"ListStacksResult>NextToken"` - StackSummaries []StackSummary `xml:"ListStacksResult>StackSummaries>member"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// ListStacks Returns the summary information for stacks whose status matches the specified StackStatusFilter. -// Summary information for stacks that have been deleted is kept for 90 days after the stack is deleted. -// If no StackStatusFilter is specified, summary information for all stacks is returned -// (including existing stacks and stacks that have been deleted). -// -// See http://goo.gl/UWi6nm for more details -func (c *CloudFormation) ListStacks(stackStatusFilters []string, nextToken string) ( - resp *ListStacksResponse, err error) { - params := makeParams("ListStacks") - - if nextToken != "" { - params["NextToken"] = nextToken - } - - if len(stackStatusFilters) > 0 { - addParamsList(params, "StackStatusFilter.member", stackStatusFilters) - } - - resp = new(ListStacksResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// SetStackPolicy sets a stack policy for a specified stack. -// -// Required Params: stackName -// -// See http://goo.gl/iY9ohu for more information -func (c *CloudFormation) SetStackPolicy(stackName, stackPolicyBody, stackPolicyUrl string) ( - resp *SimpleResp, err error) { - params := makeParams("SetStackPolicy") - - params["StackName"] = stackName - - if stackPolicyBody != "" { - params["StackPolicyBody"] = stackPolicyBody - } - if stackPolicyUrl != "" { - params["StackPolicyURL"] = stackPolicyUrl - } - - resp = new(SimpleResp) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// UpdateStackParams wraps UpdateStack request options -// -// See http://goo.gl/LvkhZq for more information -type UpdateStackParams struct { - Capabilities []string - NotificationARNs []string - Parameters []Parameter - StackName string - StackPolicyBody string - StackPolicyDuringUpdateBody string - StackPolicyDuringUpdateURL string - StackPolicyURL string - TemplateBody string - TemplateURL string - UsePreviousTemplate bool -} - -// UpdateStackResponse wraps the UpdateStack call response -// -// See http://goo.gl/LvkhZq for more information -type UpdateStackResponse struct { - StackId string `xml:"UpdateStackResult>StackId"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// UpdateStack updates a stack as specified in the template. -// After the call completes successfully, the stack update starts. -// You can check the status of the stack via the DescribeStacks action. -// -// Required Params: options.StackName -// -// See http://goo.gl/LvkhZq for more information -func (c *CloudFormation) UpdateStack(options *UpdateStackParams) ( - resp *UpdateStackResponse, err error) { - params := makeParams("UpdateStack") - - params["StackName"] = options.StackName - - if options.StackPolicyBody != "" { - params["StackPolicyBody"] = options.StackPolicyBody - } - if options.StackPolicyDuringUpdateBody != "" { - params["StackPolicyDuringUpdateBody"] = options.StackPolicyDuringUpdateBody - } - if options.StackPolicyDuringUpdateURL != "" { - params["StackPolicyDuringUpdateURL"] = options.StackPolicyDuringUpdateURL - } - if options.StackPolicyURL != "" { - params["StackPolicyURL"] = options.StackPolicyURL - } - if options.TemplateBody != "" { - params["TemplateBody"] = options.TemplateBody - } - if options.TemplateURL != "" { - params["TemplateURL"] = options.TemplateURL - } - if options.UsePreviousTemplate { - params["UsePreviousTemplate"] = strconv.FormatBool(options.UsePreviousTemplate) - } - - if len(options.Capabilities) > 0 { - addParamsList(params, "Capabilities.member", options.Capabilities) - } - if len(options.NotificationARNs) > 0 { - addParamsList(params, "NotificationARNs.member", options.NotificationARNs) - } - // Add any parameters - for i, t := range options.Parameters { - key := "Parameters.member.%d.%s" - index := i + 1 - params[fmt.Sprintf(key, index, "ParameterKey")] = t.ParameterKey - params[fmt.Sprintf(key, index, "ParameterValue")] = t.ParameterValue - params[fmt.Sprintf(key, index, "UsePreviousValue")] = strconv.FormatBool(t.UsePreviousValue) - } - - resp = new(UpdateStackResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} - -// TemplateParameter encapsulates the AWS TemplateParameter data type -// -// See http://goo.gl/OBhNzk for more information -type TemplateParameter struct { - DefaultValue string `xml:"DefaultValue"` - Description string `xml:Description"` - NoEcho bool `xml:NoEcho"` - ParameterKey string `xml:ParameterKey"` -} - -// ValidateTemplateResponse wraps the ValidateTemplate call response -// -// See http://goo.gl/OBhNzk for more information -type ValidateTemplateResponse struct { - Capabilities []string `xml:"ValidateTemplateResult>Capabilities>member"` - CapabilitiesReason string `xml:"ValidateTemplateResult>CapabilitiesReason"` - Description string `xml:"ValidateTemplateResult>Description"` - Parameters []TemplateParameter `xml:"ValidateTemplateResult>Parameters>member"` - RequestId string `xml:"ResponseMetadata>RequestId"` -} - -// ValidateTemplate validates a specified template. -// -// See http://goo.gl/OBhNzk for more information -func (c *CloudFormation) ValidateTemplate(templateBody, templateUrl string) ( - resp *ValidateTemplateResponse, err error) { - params := makeParams("ValidateTemplate") - - if templateBody != "" { - params["TemplateBody"] = templateBody - } - if templateUrl != "" { - params["TemplateURL"] = templateUrl - } - - resp = new(ValidateTemplateResponse) - if err := c.query(params, resp); err != nil { - return nil, err - } - return resp, nil -} diff --git a/vendor/github.com/goamz/goamz/cloudformation/cloudformation_test.go b/vendor/github.com/goamz/goamz/cloudformation/cloudformation_test.go deleted file mode 100644 index 1937e8042..000000000 --- a/vendor/github.com/goamz/goamz/cloudformation/cloudformation_test.go +++ /dev/null @@ -1,653 +0,0 @@ -package cloudformation_test - -import ( - "testing" - "time" - - . "gopkg.in/check.v1" - - "github.com/goamz/goamz/aws" - cf "github.com/goamz/goamz/cloudformation" - "github.com/goamz/goamz/testutil" -) - -func Test(t *testing.T) { - TestingT(t) -} - -var _ = Suite(&S{}) - -type S struct { - cf *cf.CloudFormation -} - -var testServer = testutil.NewHTTPServer() - -var mockTest bool - -func (s *S) SetUpSuite(c *C) { - testServer.Start() - auth := aws.Auth{AccessKey: "abc", SecretKey: "123"} - s.cf = cf.New(auth, aws.Region{CloudFormationEndpoint: testServer.URL}) -} - -func (s *S) TearDownTest(c *C) { - testServer.Flush() -} - -func (s *S) TestCancelUpdateStack(c *C) { - testServer.Response(200, nil, CancelUpdateStackResponse) - - resp, err := s.cf.CancelUpdateStack("foo") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "CancelUpdateStack") - c.Assert(values.Get("StackName"), Equals, "foo") - // Response test - c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE") -} - -func (s *S) TestCreateStack(c *C) { - testServer.Response(200, nil, CreateStackResponse) - - stackParams := &cf.CreateStackParams{ - NotificationARNs: []string{"arn:aws:sns:us-east-1:1234567890:my-topic"}, - Parameters: []cf.Parameter{ - { - ParameterKey: "AvailabilityZone", - ParameterValue: "us-east-1a", - }, - }, - StackName: "MyStack", - TemplateBody: "[Template Document]", - } - resp, err := s.cf.CreateStack(stackParams) - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "CreateStack") - c.Assert(values.Get("StackName"), Equals, "MyStack") - c.Assert(values.Get("NotificationARNs.member.1"), Equals, "arn:aws:sns:us-east-1:1234567890:my-topic") - c.Assert(values.Get("TemplateBody"), Equals, "[Template Document]") - c.Assert(values.Get("Parameters.member.1.ParameterKey"), Equals, "AvailabilityZone") - c.Assert(values.Get("Parameters.member.1.ParameterValue"), Equals, "us-east-1a") - // Response test - c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE") - c.Assert(resp.StackId, Equals, "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83") -} - -func (s *S) TestCreateStackWithInvalidParams(c *C) { - testServer.Response(400, nil, CreateStackWithInvalidParamsResponse) - //testServer.Response(200, nil, DeleteAutoScalingGroupResponse) - - cfTemplate := ` -{ - "AWSTemplateFormatVersion" : "2010-09-09", - "Description" : "Sample template", - "Parameters" : { - "KeyName" : { - "Description" : "key pair", - "Type" : "String" - } - }, - "Resources" : { - "Ec2Instance" : { - "Type" : "AWS::EC2::Instance", - "Properties" : { - "KeyName" : { "Ref" : "KeyName" }, - "ImageId" : "ami-7f418316", - "UserData" : { "Fn::Base64" : "80" } - } - } - }, - "Outputs" : { - "InstanceId" : { - "Description" : "InstanceId of the newly created EC2 instance", - "Value" : { "Ref" : "Ec2Instance" } - } -}` - - stackParams := &cf.CreateStackParams{ - Capabilities: []string{"CAPABILITY_IAM"}, - DisableRollback: true, - NotificationARNs: []string{ - "arn:aws:sns:us-east-1:1234567890:my-topic", - "arn:aws:sns:us-east-1:1234567890:my-topic2", - }, - OnFailure: "ROLLBACK", - Parameters: []cf.Parameter{ - { - ParameterKey: "AvailabilityZone", - ParameterValue: "us-east-1a", - }, - }, - StackName: "MyStack", - StackPolicyBody: "{PolicyBody}", - StackPolicyURL: "http://stack-policy-url", - Tags: []cf.Tag{ - { - Key: "TagKey", - Value: "TagValue", - }, - }, - TemplateBody: cfTemplate, - TemplateURL: "http://url", - TimeoutInMinutes: 20, - } - resp, err := s.cf.CreateStack(stackParams) - c.Assert(err, NotNil) - c.Assert(resp, IsNil) - values := testServer.WaitRequest().PostForm - - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "CreateStack") - c.Assert(values.Get("StackName"), Equals, "MyStack") - c.Assert(values.Get("NotificationARNs.member.1"), Equals, "arn:aws:sns:us-east-1:1234567890:my-topic") - c.Assert(values.Get("NotificationARNs.member.2"), Equals, "arn:aws:sns:us-east-1:1234567890:my-topic2") - c.Assert(values.Get("Capabilities.member.1"), Equals, "CAPABILITY_IAM") - c.Assert(values.Get("TemplateBody"), Equals, cfTemplate) - c.Assert(values.Get("TemplateURL"), Equals, "http://url") - c.Assert(values.Get("StackPolicyBody"), Equals, "{PolicyBody}") - c.Assert(values.Get("StackPolicyURL"), Equals, "http://stack-policy-url") - c.Assert(values.Get("OnFailure"), Equals, "ROLLBACK") - c.Assert(values.Get("DisableRollback"), Equals, "true") - c.Assert(values.Get("Tags.member.1.Key"), Equals, "TagKey") - c.Assert(values.Get("Tags.member.1.Value"), Equals, "TagValue") - c.Assert(values.Get("Parameters.member.1.ParameterKey"), Equals, "AvailabilityZone") - c.Assert(values.Get("Parameters.member.1.ParameterValue"), Equals, "us-east-1a") - c.Assert(values.Get("TimeoutInMinutes"), Equals, "20") - - // Response test - c.Assert(err.(*cf.Error).RequestId, Equals, "70a76d42-9665-11e2-9fdf-211deEXAMPLE") - c.Assert(err.(*cf.Error).Message, Equals, "Either Template URL or Template Body must be specified.") - c.Assert(err.(*cf.Error).Type, Equals, "Sender") - c.Assert(err.(*cf.Error).Code, Equals, "ValidationError") - c.Assert(err.(*cf.Error).StatusCode, Equals, 400) - -} - -func (s *S) TestDeleteStack(c *C) { - testServer.Response(200, nil, DeleteStackResponse) - - resp, err := s.cf.DeleteStack("foo") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "DeleteStack") - c.Assert(values.Get("StackName"), Equals, "foo") - // Response test - c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE") -} - -func (s *S) TestDescribeStackEvents(c *C) { - testServer.Response(200, nil, DescribeStackEventsResponse) - - resp, err := s.cf.DescribeStackEvents("MyStack", "") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - - // Post request test - t1, _ := time.Parse(time.RFC3339, "2010-07-27T22:26:28Z") - t2, _ := time.Parse(time.RFC3339, "2010-07-27T22:27:28Z") - t3, _ := time.Parse(time.RFC3339, "2010-07-27T22:28:28Z") - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "DescribeStackEvents") - c.Assert(values.Get("StackName"), Equals, "MyStack") - c.Assert(values.Get("NextToken"), Equals, "") - - // Response test - expected := &cf.DescribeStackEventsResponse{ - StackEvents: []cf.StackEvent{ - { - EventId: "Event-1-Id", - StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83", - StackName: "MyStack", - LogicalResourceId: "MyStack", - PhysicalResourceId: "MyStack_One", - ResourceType: "AWS::CloudFormation::Stack", - Timestamp: t1, - ResourceStatus: "CREATE_IN_PROGRESS", - ResourceStatusReason: "User initiated", - }, - { - EventId: "Event-2-Id", - StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83", - StackName: "MyStack", - LogicalResourceId: "MyDBInstance", - PhysicalResourceId: "MyStack_DB1", - ResourceType: "AWS::SecurityGroup", - Timestamp: t2, - ResourceStatus: "CREATE_IN_PROGRESS", - ResourceProperties: "{\"GroupDescription\":...}", - }, - { - EventId: "Event-3-Id", - StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83", - StackName: "MyStack", - LogicalResourceId: "MySG1", - PhysicalResourceId: "MyStack_SG1", - ResourceType: "AWS::SecurityGroup", - Timestamp: t3, - ResourceStatus: "CREATE_COMPLETE", - }, - }, - NextToken: "", - RequestId: "4af14eec-350e-11e4-b260-EXAMPLE", - } - c.Assert(resp, DeepEquals, expected) -} - -func (s *S) TestDescribeStackResource(c *C) { - testServer.Response(200, nil, DescribeStackResourceResponse) - - resp, err := s.cf.DescribeStackResource("MyStack", "MyDBInstance") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "DescribeStackResource") - c.Assert(values.Get("StackName"), Equals, "MyStack") - c.Assert(values.Get("LogicalResourceId"), Equals, "MyDBInstance") - t, _ := time.Parse(time.RFC3339, "2011-07-07T22:27:28Z") - // Response test - expected := &cf.DescribeStackResourceResponse{ - StackResourceDetail: cf.StackResourceDetail{ - StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83", - StackName: "MyStack", - LogicalResourceId: "MyDBInstance", - PhysicalResourceId: "MyStack_DB1", - ResourceType: "AWS::RDS::DBInstance", - LastUpdatedTimestamp: t, - ResourceStatus: "CREATE_COMPLETE", - }, - RequestId: "4af14eec-350e-11e4-b260-EXAMPLE", - } - c.Assert(resp, DeepEquals, expected) -} - -func (s *S) TestDescribeStackResources(c *C) { - testServer.Response(200, nil, DescribeStackResourcesResponse) - - resp, err := s.cf.DescribeStackResources("MyStack", "", "") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - - // Post request test - t1, _ := time.Parse(time.RFC3339, "2010-07-27T22:27:28Z") - t2, _ := time.Parse(time.RFC3339, "2010-07-27T22:28:28Z") - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "DescribeStackResources") - c.Assert(values.Get("StackName"), Equals, "MyStack") - c.Assert(values.Get("PhysicalResourceId"), Equals, "") - c.Assert(values.Get("LogicalResourceId"), Equals, "") - - // Response test - expected := &cf.DescribeStackResourcesResponse{ - StackResources: []cf.StackResource{ - { - StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83", - StackName: "MyStack", - LogicalResourceId: "MyDBInstance", - PhysicalResourceId: "MyStack_DB1", - ResourceType: "AWS::DBInstance", - Timestamp: t1, - ResourceStatus: "CREATE_COMPLETE", - }, - { - StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83", - StackName: "MyStack", - LogicalResourceId: "MyAutoScalingGroup", - PhysicalResourceId: "MyStack_ASG1", - ResourceType: "AWS::AutoScalingGroup", - Timestamp: t2, - ResourceStatus: "CREATE_IN_PROGRESS", - }, - }, - RequestId: "4af14eec-350e-11e4-b260-EXAMPLE", - } - c.Assert(resp, DeepEquals, expected) -} - -func (s *S) TestDescribeStacks(c *C) { - testServer.Response(200, nil, DescribeStacksResponse) - - resp, err := s.cf.DescribeStacks("MyStack", "") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - - // Post request test - t, _ := time.Parse(time.RFC3339, "2010-07-27T22:28:28Z") - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "DescribeStacks") - c.Assert(values.Get("StackName"), Equals, "MyStack") - c.Assert(values.Get("NextToken"), Equals, "") - - // Response test - expected := &cf.DescribeStacksResponse{ - Stacks: []cf.Stack{ - { - StackId: "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83", - StackName: "MyStack", - Description: "My Description", - Capabilities: []string{"CAPABILITY_IAM"}, - NotificationARNs: []string{"arn:aws:sns:region-name:account-name:topic-name"}, - Parameters: []cf.Parameter{ - { - ParameterKey: "MyKey", - ParameterValue: "MyValue", - }, - }, - Tags: []cf.Tag{ - { - Key: "MyTagKey", - Value: "MyTagValue", - }, - }, - CreationTime: t, - StackStatus: "CREATE_COMPLETE", - DisableRollback: false, - Outputs: []cf.Output{ - { - Description: "ServerUrl", - OutputKey: "StartPage", - OutputValue: "http://my-load-balancer.amazonaws.com:80/index.html", - }, - }, - }, - }, - NextToken: "", - RequestId: "4af14eec-350e-11e4-b260-EXAMPLE", - } - c.Assert(resp, DeepEquals, expected) -} - -func (s *S) TestEstimateTemplateCost(c *C) { - testServer.Response(200, nil, EstimateTemplateCostResponse) - - resp, err := s.cf.EstimateTemplateCost(nil, "", "https://s3.amazonaws.com/cloudformation-samples-us-east-1/Drupal_Simple.template") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "EstimateTemplateCost") - c.Assert(values.Get("TemplateBody"), Equals, "") - c.Assert(values.Get("TemplateURL"), Equals, "https://s3.amazonaws.com/cloudformation-samples-us-east-1/Drupal_Simple.template") - // Response test - c.Assert(resp.Url, Equals, "http://calculator.s3.amazonaws.com/calc5.html?key=cf-2e351785-e821-450c-9d58-625e1e1ebfb6") - c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE") -} - -func (s *S) TestGetStackPolicy(c *C) { - testServer.Response(200, nil, GetStackPolicyResponse) - - resp, err := s.cf.GetStackPolicy("MyStack") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "GetStackPolicy") - - c.Assert(values.Get("StackName"), Equals, "MyStack") - // Response test - policy := `{ - "Statement" : [ - { - "Effect" : "Deny", - "Action" : "Update:*", - "Principal" : "*", - "Resource" : "LogicalResourceId/ProductionDatabase" - }, - { - "Effect" : "Allow", - "Action" : "Update:*", - "Principal" : "*", - "Resource" : "*" - } - ] - }` - c.Assert(resp.StackPolicyBody, Equals, policy) - c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE") -} - -func (s *S) TestGetTemplate(c *C) { - testServer.Response(200, nil, GetTemplateResponse) - - resp, err := s.cf.GetTemplate("MyStack") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "GetTemplate") - - c.Assert(values.Get("StackName"), Equals, "MyStack") - // Response test - templateBody := `{ - "AWSTemplateFormatVersion" : "2010-09-09", - "Description" : "Simple example", - "Resources" : { - "MySQS" : { - "Type" : "AWS::SQS::Queue", - "Properties" : { - } - } - } - }` - c.Assert(resp.TemplateBody, Equals, templateBody) - c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE") -} - -func (s *S) TestListStackResources(c *C) { - testServer.Response(200, nil, ListStackResourcesResponse) - - resp, err := s.cf.ListStackResources("MyStack", "4dad1-32131da-d-31") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "ListStackResources") - c.Assert(values.Get("StackName"), Equals, "MyStack") - c.Assert(values.Get("NextToken"), Equals, "4dad1-32131da-d-31") - - // Response test - t1, _ := time.Parse(time.RFC3339, "2011-06-21T20:15:58Z") - t2, _ := time.Parse(time.RFC3339, "2011-06-21T20:25:57Z") - t3, _ := time.Parse(time.RFC3339, "2011-06-21T20:26:12Z") - t4, _ := time.Parse(time.RFC3339, "2011-06-21T20:28:48Z") - t5, _ := time.Parse(time.RFC3339, "2011-06-21T20:29:06Z") - t6, _ := time.Parse(time.RFC3339, "2011-06-21T20:29:23Z") - - expected := &cf.ListStackResourcesResponse{ - StackResourceSummaries: []cf.StackResourceSummary{ - { - LogicalResourceId: "DBSecurityGroup", - PhysicalResourceId: "gmarcteststack-dbsecuritygroup-1s5m0ez5lkk6w", - ResourceType: "AWS::RDS::DBSecurityGroup", - LastUpdatedTimestamp: t1, - ResourceStatus: "CREATE_COMPLETE", - }, - { - LogicalResourceId: "SampleDB", - PhysicalResourceId: "MyStack-sampledb-ycwhk1v830lx", - ResourceType: "AWS::RDS::DBInstance", - LastUpdatedTimestamp: t2, - ResourceStatus: "CREATE_COMPLETE", - }, - { - LogicalResourceId: "SampleApplication", - PhysicalResourceId: "MyStack-SampleApplication-1MKNASYR3RBQL", - ResourceType: "AWS::ElasticBeanstalk::Application", - LastUpdatedTimestamp: t3, - ResourceStatus: "CREATE_COMPLETE", - }, - { - LogicalResourceId: "SampleEnvironment", - PhysicalResourceId: "myst-Samp-1AGU6ERZX6M3Q", - ResourceType: "AWS::ElasticBeanstalk::Environment", - LastUpdatedTimestamp: t4, - ResourceStatus: "CREATE_COMPLETE", - }, - { - LogicalResourceId: "AlarmTopic", - PhysicalResourceId: "arn:aws:sns:us-east-1:803981987763:MyStack-AlarmTopic-SW4IQELG7RPJ", - ResourceType: "AWS::SNS::Topic", - LastUpdatedTimestamp: t5, - ResourceStatus: "CREATE_COMPLETE", - }, - { - LogicalResourceId: "CPUAlarmHigh", - PhysicalResourceId: "MyStack-CPUAlarmHigh-POBWQPDJA81F", - ResourceType: "AWS::CloudWatch::Alarm", - LastUpdatedTimestamp: t6, - ResourceStatus: "CREATE_COMPLETE", - }, - }, - NextToken: "", - RequestId: "2d06e36c-ac1d-11e0-a958-f9382b6eb86b", - } - c.Assert(resp, DeepEquals, expected) -} - -func (s *S) TestListStacks(c *C) { - testServer.Response(200, nil, ListStacksResponse) - - resp, err := s.cf.ListStacks([]string{"CREATE_IN_PROGRESS", "DELETE_COMPLETE"}, "4dad1-32131da-d-31") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "ListStacks") - c.Assert(values.Get("StackStatusFilter.member.1"), Equals, "CREATE_IN_PROGRESS") - c.Assert(values.Get("StackStatusFilter.member.2"), Equals, "DELETE_COMPLETE") - c.Assert(values.Get("NextToken"), Equals, "4dad1-32131da-d-31") - - // Response test - c1, _ := time.Parse(time.RFC3339, "2011-05-23T15:47:44Z") - c2, _ := time.Parse(time.RFC3339, "2011-03-05T19:57:58Z") - d2, _ := time.Parse(time.RFC3339, "2011-03-10T16:20:51Z") - - expected := &cf.ListStacksResponse{ - StackSummaries: []cf.StackSummary{ - { - StackId: "arn:aws:cloudformation:us-east-1:1234567:stack/TestCreate1/aaaaa", - StackName: "vpc1", - StackStatus: "CREATE_IN_PROGRESS", - CreationTime: c1, - TemplateDescription: "Creates one EC2 instance and a load balancer.", - }, - { - StackId: "arn:aws:cloudformation:us-east-1:1234567:stack/TestDelete2/bbbbb", - StackName: "WP1", - StackStatus: "DELETE_COMPLETE", - CreationTime: c2, - DeletionTime: d2, - TemplateDescription: "A simple basic Cloudformation Template.", - }, - }, - NextToken: "", - RequestId: "2d06e36c-ac1d-11e0-a958-f9382b6eb86b", - } - c.Assert(resp, DeepEquals, expected) -} - -func (s *S) TestSetStackPolicy(c *C) { - testServer.Response(200, nil, SetStackPolicyResponse) - - resp, err := s.cf.SetStackPolicy("MyStack", "[Stack Policy Document]", "") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "SetStackPolicy") - c.Assert(values.Get("StackName"), Equals, "MyStack") - c.Assert(values.Get("StackPolicyBody"), Equals, "[Stack Policy Document]") - c.Assert(values.Get("StackPolicyUrl"), Equals, "") - // Response test - c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE") -} - -func (s *S) TestUpdateStack(c *C) { - testServer.Response(200, nil, UpdateStackResponse) - - stackParams := &cf.UpdateStackParams{ - Capabilities: []string{"CAPABILITY_IAM"}, - NotificationARNs: []string{"arn:aws:sns:us-east-1:1234567890:my-topic"}, - StackPolicyBody: "{PolicyBody}", - StackPolicyDuringUpdateBody: "{PolicyDuringUpdateBody}", - Parameters: []cf.Parameter{ - { - ParameterKey: "AvailabilityZone", - ParameterValue: "us-east-1a", - }, - }, - UsePreviousTemplate: true, - StackName: "MyStack", - TemplateBody: "[Template Document]", - } - resp, err := s.cf.UpdateStack(stackParams) - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "UpdateStack") - c.Assert(values.Get("StackName"), Equals, "MyStack") - c.Assert(values.Get("NotificationARNs.member.1"), Equals, "arn:aws:sns:us-east-1:1234567890:my-topic") - c.Assert(values.Get("TemplateBody"), Equals, "[Template Document]") - c.Assert(values.Get("Parameters.member.1.ParameterKey"), Equals, "AvailabilityZone") - c.Assert(values.Get("Parameters.member.1.ParameterValue"), Equals, "us-east-1a") - c.Assert(values.Get("Capabilities.member.1"), Equals, "CAPABILITY_IAM") - c.Assert(values.Get("StackPolicyBody"), Equals, "{PolicyBody}") - c.Assert(values.Get("StackPolicyDuringUpdateBody"), Equals, "{PolicyDuringUpdateBody}") - c.Assert(values.Get("UsePreviousTemplate"), Equals, "true") - - // Response test - c.Assert(resp.RequestId, Equals, "4af14eec-350e-11e4-b260-EXAMPLE") - c.Assert(resp.StackId, Equals, "arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83") -} - -func (s *S) TestValidateTemplate(c *C) { - testServer.Response(200, nil, ValidateTemplateResponse) - - resp, err := s.cf.ValidateTemplate("", "http://myTemplateRepository/TemplateOne.template") - c.Assert(err, IsNil) - values := testServer.WaitRequest().PostForm - - // Post request test - c.Assert(values.Get("Version"), Equals, "2010-05-15") - c.Assert(values.Get("Action"), Equals, "ValidateTemplate") - c.Assert(values.Get("TemplateURL"), Equals, "http://myTemplateRepository/TemplateOne.template") - c.Assert(values.Get("TemplateBody"), Equals, "") - - // Response test - expected := &cf.ValidateTemplateResponse{ - Description: "Test", - Capabilities: []string{"CAPABILITY_IAM"}, - Parameters: []cf.TemplateParameter{ - { - NoEcho: false, - ParameterKey: "InstanceType", - Description: "Type of instance to launch", - DefaultValue: "m1.small", - }, - { - NoEcho: false, - ParameterKey: "WebServerPort", - Description: "The TCP port for the Web Server", - DefaultValue: "8888", - }, - { - NoEcho: false, - ParameterKey: "KeyName", - Description: "Name of an existing EC2 KeyPair to enable SSH access into the server", - }, - }, - RequestId: "0be7b6e8-e4a0-11e0-a5bd-9f8d5a7dbc91", - } - c.Assert(resp, DeepEquals, expected) -} diff --git a/vendor/github.com/goamz/goamz/cloudformation/responses_test.go b/vendor/github.com/goamz/goamz/cloudformation/responses_test.go deleted file mode 100644 index 705b1d976..000000000 --- a/vendor/github.com/goamz/goamz/cloudformation/responses_test.go +++ /dev/null @@ -1,371 +0,0 @@ -package cloudformation_test - -var CancelUpdateStackResponse = ` -<CancelUpdateStackResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <CancelUpdateStackResult/> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</CancelUpdateStackResponse> -` - -var CreateStackResponse = ` -<CreateStackResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> -<CreateStackResult> - <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId> -</CreateStackResult> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</CreateStackResponse> -` - -var CreateStackWithInvalidParamsResponse = ` -<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <Error> - <Type>Sender</Type> - <Code>ValidationError</Code> - <Message>Either Template URL or Template Body must be specified.</Message> - </Error> - <RequestId>70a76d42-9665-11e2-9fdf-211deEXAMPLE</RequestId> -</ErrorResponse> -` - -var DeleteStackResponse = ` -<DeleteStackResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <DeleteStackResult/> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</DeleteStackResponse> -` -var DescribeStackEventsResponse = ` -<DescribeStackEventsResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <DescribeStackEventsResult> - <StackEvents> - <member> - <EventId>Event-1-Id</EventId> - <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId> - <StackName>MyStack</StackName> - <LogicalResourceId>MyStack</LogicalResourceId> - <PhysicalResourceId>MyStack_One</PhysicalResourceId> - <ResourceType>AWS::CloudFormation::Stack</ResourceType> - <Timestamp>2010-07-27T22:26:28Z</Timestamp> - <ResourceStatus>CREATE_IN_PROGRESS</ResourceStatus> - <ResourceStatusReason>User initiated</ResourceStatusReason> - </member> - <member> - <EventId>Event-2-Id</EventId> - <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId> - <StackName>MyStack</StackName> - <LogicalResourceId>MyDBInstance</LogicalResourceId> - <PhysicalResourceId>MyStack_DB1</PhysicalResourceId> - <ResourceType>AWS::SecurityGroup</ResourceType> - <Timestamp>2010-07-27T22:27:28Z</Timestamp> - <ResourceStatus>CREATE_IN_PROGRESS</ResourceStatus> - <ResourceProperties>{"GroupDescription":...}</ResourceProperties> - </member> - <member> - <EventId>Event-3-Id</EventId> - <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId> - <StackName>MyStack</StackName> - <LogicalResourceId>MySG1</LogicalResourceId> - <PhysicalResourceId>MyStack_SG1</PhysicalResourceId> - <ResourceType>AWS::SecurityGroup</ResourceType> - <Timestamp>2010-07-27T22:28:28Z</Timestamp> - <ResourceStatus>CREATE_COMPLETE</ResourceStatus> - </member> - </StackEvents> - <NextToken/> - </DescribeStackEventsResult> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</DescribeStackEventsResponse> -` - -var DescribeStackResourceResponse = ` -<DescribeStackResourceResponse> - <DescribeStackResourceResult> - <StackResourceDetail> - <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId> - <StackName>MyStack</StackName> - <LogicalResourceId>MyDBInstance</LogicalResourceId> - <PhysicalResourceId>MyStack_DB1</PhysicalResourceId> - <ResourceType>AWS::RDS::DBInstance</ResourceType> - <LastUpdatedTimestamp>2011-07-07T22:27:28Z</LastUpdatedTimestamp> - <ResourceStatus>CREATE_COMPLETE</ResourceStatus> - </StackResourceDetail> - </DescribeStackResourceResult> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</DescribeStackResourceResponse> -` -var DescribeStackResourcesResponse = ` -<DescribeStackResourcesResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <DescribeStackResourcesResult> - <StackResources> - <member> - <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId> - <StackName>MyStack</StackName> - <LogicalResourceId>MyDBInstance</LogicalResourceId> - <PhysicalResourceId>MyStack_DB1</PhysicalResourceId> - <ResourceType>AWS::DBInstance</ResourceType> - <Timestamp>2010-07-27T22:27:28Z</Timestamp> - <ResourceStatus>CREATE_COMPLETE</ResourceStatus> - </member> - <member> - <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId> - <StackName>MyStack</StackName> - <LogicalResourceId>MyAutoScalingGroup</LogicalResourceId> - <PhysicalResourceId>MyStack_ASG1</PhysicalResourceId> - <ResourceType>AWS::AutoScalingGroup</ResourceType> - <Timestamp>2010-07-27T22:28:28Z</Timestamp> - <ResourceStatus>CREATE_IN_PROGRESS</ResourceStatus> - </member> - </StackResources> - </DescribeStackResourcesResult> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</DescribeStackResourcesResponse> -` - -var DescribeStacksResponse = ` -<DescribeStacksResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <DescribeStacksResult> - <Stacks> - <member> - <StackName>MyStack</StackName> - <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId> - <StackStatusReason/> - <Description>My Description</Description> - <Capabilities> - <member>CAPABILITY_IAM</member> - </Capabilities> - <NotificationARNs> - <member>arn:aws:sns:region-name:account-name:topic-name</member> - </NotificationARNs> - <Parameters> - <member> - <ParameterValue>MyValue</ParameterValue> - <ParameterKey>MyKey</ParameterKey> - </member> - </Parameters> - <Tags> - <member> - <Key>MyTagKey</Key> - <Value>MyTagValue</Value> - </member> - </Tags> - <CreationTime>2010-07-27T22:28:28Z</CreationTime> - <StackStatus>CREATE_COMPLETE</StackStatus> - <DisableRollback>false</DisableRollback> - <Outputs> - <member> - <Description>ServerUrl</Description> - <OutputKey>StartPage</OutputKey> - <OutputValue>http://my-load-balancer.amazonaws.com:80/index.html</OutputValue> - </member> - </Outputs> - </member> - </Stacks> - <NextToken/> - </DescribeStacksResult> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</DescribeStacksResponse> -` - -var EstimateTemplateCostResponse = ` -<EstimateTemplateCostResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <EstimateTemplateCostResult> - <Url>http://calculator.s3.amazonaws.com/calc5.html?key=cf-2e351785-e821-450c-9d58-625e1e1ebfb6</Url> - </EstimateTemplateCostResult> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</EstimateTemplateCostResponse> -` - -var GetStackPolicyResponse = ` -<GetStackPolicyResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <GetStackPolicyResult> - <StackPolicyBody>{ - "Statement" : [ - { - "Effect" : "Deny", - "Action" : "Update:*", - "Principal" : "*", - "Resource" : "LogicalResourceId/ProductionDatabase" - }, - { - "Effect" : "Allow", - "Action" : "Update:*", - "Principal" : "*", - "Resource" : "*" - } - ] - }</StackPolicyBody> - </GetStackPolicyResult> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</GetStackPolicyResponse> -` - -var GetTemplateResponse = ` -<GetTemplateResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <GetTemplateResult> - <TemplateBody>{ - "AWSTemplateFormatVersion" : "2010-09-09", - "Description" : "Simple example", - "Resources" : { - "MySQS" : { - "Type" : "AWS::SQS::Queue", - "Properties" : { - } - } - } - }</TemplateBody> - </GetTemplateResult> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</GetTemplateResponse> -` - -var ListStackResourcesResponse = ` -<ListStackResourcesResponse> - <ListStackResourcesResult> - <StackResourceSummaries> - <member> - <ResourceStatus>CREATE_COMPLETE</ResourceStatus> - <LogicalResourceId>DBSecurityGroup</LogicalResourceId> - <LastUpdatedTimestamp>2011-06-21T20:15:58Z</LastUpdatedTimestamp> - <PhysicalResourceId>gmarcteststack-dbsecuritygroup-1s5m0ez5lkk6w</PhysicalResourceId> - <ResourceType>AWS::RDS::DBSecurityGroup</ResourceType> - </member> - <member> - <ResourceStatus>CREATE_COMPLETE</ResourceStatus> - <LogicalResourceId>SampleDB</LogicalResourceId> - <LastUpdatedTimestamp>2011-06-21T20:25:57Z</LastUpdatedTimestamp> - <PhysicalResourceId>MyStack-sampledb-ycwhk1v830lx</PhysicalResourceId> - <ResourceType>AWS::RDS::DBInstance</ResourceType> - </member> - <member> - <ResourceStatus>CREATE_COMPLETE</ResourceStatus> - <LogicalResourceId>SampleApplication</LogicalResourceId> - <LastUpdatedTimestamp>2011-06-21T20:26:12Z</LastUpdatedTimestamp> - <PhysicalResourceId>MyStack-SampleApplication-1MKNASYR3RBQL</PhysicalResourceId> - <ResourceType>AWS::ElasticBeanstalk::Application</ResourceType> - </member> - <member> - <ResourceStatus>CREATE_COMPLETE</ResourceStatus> - <LogicalResourceId>SampleEnvironment</LogicalResourceId> - <LastUpdatedTimestamp>2011-06-21T20:28:48Z</LastUpdatedTimestamp> - <PhysicalResourceId>myst-Samp-1AGU6ERZX6M3Q</PhysicalResourceId> - <ResourceType>AWS::ElasticBeanstalk::Environment</ResourceType> - </member> - <member> - <ResourceStatus>CREATE_COMPLETE</ResourceStatus> - <LogicalResourceId>AlarmTopic</LogicalResourceId> - <LastUpdatedTimestamp>2011-06-21T20:29:06Z</LastUpdatedTimestamp> - <PhysicalResourceId>arn:aws:sns:us-east-1:803981987763:MyStack-AlarmTopic-SW4IQELG7RPJ</PhysicalResourceId> - <ResourceType>AWS::SNS::Topic</ResourceType> - </member> - <member> - <ResourceStatus>CREATE_COMPLETE</ResourceStatus> - <LogicalResourceId>CPUAlarmHigh</LogicalResourceId> - <LastUpdatedTimestamp>2011-06-21T20:29:23Z</LastUpdatedTimestamp> - <PhysicalResourceId>MyStack-CPUAlarmHigh-POBWQPDJA81F</PhysicalResourceId> - <ResourceType>AWS::CloudWatch::Alarm</ResourceType> - </member> - </StackResourceSummaries> - </ListStackResourcesResult> - <ResponseMetadata> - <RequestId>2d06e36c-ac1d-11e0-a958-f9382b6eb86b</RequestId> - </ResponseMetadata> -</ListStackResourcesResponse> -` - -var ListStacksResponse = ` -<ListStacksResponse> - <ListStacksResult> - <StackSummaries> - <member> - <StackId>arn:aws:cloudformation:us-east-1:1234567:stack/TestCreate1/aaaaa</StackId> - <StackStatus>CREATE_IN_PROGRESS</StackStatus> - <StackName>vpc1</StackName> - <CreationTime>2011-05-23T15:47:44Z</CreationTime> - <TemplateDescription>Creates one EC2 instance and a load balancer.</TemplateDescription> - </member> - <member> - <StackId>arn:aws:cloudformation:us-east-1:1234567:stack/TestDelete2/bbbbb</StackId> - <StackStatus>DELETE_COMPLETE</StackStatus> - <DeletionTime>2011-03-10T16:20:51Z</DeletionTime> - <StackName>WP1</StackName> - <CreationTime>2011-03-05T19:57:58Z</CreationTime> - <TemplateDescription>A simple basic Cloudformation Template.</TemplateDescription> - </member> - </StackSummaries> - </ListStacksResult> - <ResponseMetadata> - <RequestId>2d06e36c-ac1d-11e0-a958-f9382b6eb86b</RequestId> - </ResponseMetadata> -</ListStacksResponse> -` - -var SetStackPolicyResponse = ` -<SetStackPolicyResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <SetStackPolicyResponse/> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</SetStackPolicyResponse> -` - -var UpdateStackResponse = ` -<UpdateStackResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <UpdateStackResult> - <StackId>arn:aws:cloudformation:us-east-1:123456789:stack/MyStack/aaf549a0-a413-11df-adb3-5081b3858e83</StackId> - </UpdateStackResult> - <ResponseMetadata> - <RequestId>4af14eec-350e-11e4-b260-EXAMPLE</RequestId> - </ResponseMetadata> -</UpdateStackResponse> -` -var ValidateTemplateResponse = ` -<ValidateTemplateResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/"> - <ValidateTemplateResult> - <Description>Test</Description> - <Capabilities> - <member>CAPABILITY_IAM</member> - </Capabilities> - <Parameters> - <member> - <NoEcho>false</NoEcho> - <ParameterKey>InstanceType</ParameterKey> - <Description>Type of instance to launch</Description> - <DefaultValue>m1.small</DefaultValue> - </member> - <member> - <NoEcho>false</NoEcho> - <ParameterKey>WebServerPort</ParameterKey> - <Description>The TCP port for the Web Server</Description> - <DefaultValue>8888</DefaultValue> - </member> - <member> - <NoEcho>false</NoEcho> - <ParameterKey>KeyName</ParameterKey> - <Description>Name of an existing EC2 KeyPair to enable SSH access into the server</Description> - </member> - </Parameters> - </ValidateTemplateResult> - <ResponseMetadata> - <RequestId>0be7b6e8-e4a0-11e0-a5bd-9f8d5a7dbc91</RequestId> - </ResponseMetadata> -</ValidateTemplateResponse> -` |