diff --git a/aws/aws.go b/aws/aws.go index cfc42c03..a6832a0f 100644 --- a/aws/aws.go +++ b/aws/aws.go @@ -33,6 +33,7 @@ type Region struct { SNSEndpoint string SQSEndpoint string IAMEndpoint string + EBEndpoint string ELBEndpoint string AutoScalingEndpoint string RdsEndpoint string @@ -50,6 +51,7 @@ var USGovWest = Region{ "https://sns.us-gov-west-1.amazonaws.com", "https://sqs.us-gov-west-1.amazonaws.com", "https://iam.us-gov.amazonaws.com", + "", "https://elasticloadbalancing.us-gov-west-1.amazonaws.com", "https://autoscaling.us-gov-west-1.amazonaws.com", "https://rds.us-gov-west-1.amazonaws.com", @@ -67,6 +69,7 @@ var USEast = Region{ "https://sns.us-east-1.amazonaws.com", "https://sqs.us-east-1.amazonaws.com", "https://iam.amazonaws.com", + "https://elasticbeanstalk.us-east-1.amazonaws.com", "https://elasticloadbalancing.us-east-1.amazonaws.com", "https://autoscaling.us-east-1.amazonaws.com", "https://rds.us-east-1.amazonaws.com", @@ -84,6 +87,7 @@ var USWest = Region{ "https://sns.us-west-1.amazonaws.com", "https://sqs.us-west-1.amazonaws.com", "https://iam.amazonaws.com", + "https://elasticbeanstalk.us-west-1.amazonaws.com", "https://elasticloadbalancing.us-west-1.amazonaws.com", "https://autoscaling.us-west-1.amazonaws.com", "https://rds.us-west-1.amazonaws.com", @@ -101,6 +105,7 @@ var USWest2 = Region{ "https://sns.us-west-2.amazonaws.com", "https://sqs.us-west-2.amazonaws.com", "https://iam.amazonaws.com", + "https://elasticbeanstalk.us-west-2.amazonaws.com", "https://elasticloadbalancing.us-west-2.amazonaws.com", "https://autoscaling.us-west-2.amazonaws.com", "https://rds.us-west-2.amazonaws.com", @@ -118,6 +123,7 @@ var EUWest = Region{ "https://sns.eu-west-1.amazonaws.com", "https://sqs.eu-west-1.amazonaws.com", "https://iam.amazonaws.com", + "https://elasticbeanstalk.eu-west-1.amazonaws.com", "https://elasticloadbalancing.eu-west-1.amazonaws.com", "https://autoscaling.eu-west-1.amazonaws.com", "https://rds.eu-west-1.amazonaws.com", @@ -135,6 +141,7 @@ var EUCentral = Region{ "https://sns.eu-central-1.amazonaws.com", "https://sqs.eu-central-1.amazonaws.com", "https://iam.amazonaws.com", + "https://elasticbeanstalk.eu-central-1.amazonaws.com", "https://elasticloadbalancing.eu-central-1.amazonaws.com", "https://autoscaling.eu-central-1.amazonaws.com", "https://rds.eu-central-1.amazonaws.com", @@ -152,6 +159,7 @@ var APSoutheast = Region{ "https://sns.ap-southeast-1.amazonaws.com", "https://sqs.ap-southeast-1.amazonaws.com", "https://iam.amazonaws.com", + "https://elasticbeanstalk.ap-southeast-1.amazonaws.com", "https://elasticloadbalancing.ap-southeast-1.amazonaws.com", "https://autoscaling.ap-southeast-1.amazonaws.com", "https://rds.ap-southeast-1.amazonaws.com", @@ -169,6 +177,7 @@ var APSoutheast2 = Region{ "https://sns.ap-southeast-2.amazonaws.com", "https://sqs.ap-southeast-2.amazonaws.com", "https://iam.amazonaws.com", + "https://elasticbeanstalk.ap-southeast-2.amazonaws.com", "https://elasticloadbalancing.ap-southeast-2.amazonaws.com", "https://autoscaling.ap-southeast-2.amazonaws.com", "https://rds.ap-southeast-2.amazonaws.com", @@ -186,6 +195,7 @@ var APNortheast = Region{ "https://sns.ap-northeast-1.amazonaws.com", "https://sqs.ap-northeast-1.amazonaws.com", "https://iam.amazonaws.com", + "https://elasticbeanstalk.ap-northeast-1.amazonaws.com", "https://elasticloadbalancing.ap-northeast-1.amazonaws.com", "https://autoscaling.ap-northeast-1.amazonaws.com", "https://rds.ap-northeast-1.amazonaws.com", @@ -203,6 +213,7 @@ var SAEast = Region{ "https://sns.sa-east-1.amazonaws.com", "https://sqs.sa-east-1.amazonaws.com", "https://iam.amazonaws.com", + "https://elasticbeanstalk.sa-east-1.amazonaws.com", "https://elasticloadbalancing.sa-east-1.amazonaws.com", "https://autoscaling.sa-east-1.amazonaws.com", "https://rds.sa-east-1.amazonaws.com", @@ -220,6 +231,7 @@ var CNNorth = Region{ "https://sns.cn-north-1.amazonaws.com.cn", "https://sqs.cn-north-1.amazonaws.com.cn", "https://iam.cn-north-1.amazonaws.com.cn", + "", "https://elasticloadbalancing.cn-north-1.amazonaws.com.cn", "https://autoscaling.cn-north-1.amazonaws.com.cn", "https://rds.cn-north-1.amazonaws.com.cn", diff --git a/eb/eb.go b/eb/eb.go new file mode 100644 index 00000000..52b2cc66 --- /dev/null +++ b/eb/eb.go @@ -0,0 +1,1335 @@ +// The eb package provides types and functions for interaction with the AWS +// Elastic Beanstalk service (EB) +package eb + +import ( + "encoding/xml" + "github.com/mitchellh/goamz/aws" + "net/http" + "net/url" + "strconv" + "time" +) + +type EB struct { + aws.Auth + aws.Region + httpClient *http.Client +} + +const APIVersion = "2010-12-01" + +// New creates a new ELB instance. +func New(auth aws.Auth, region aws.Region) *EB { + return NewWithClient(auth, region, aws.RetryingClient) +} + +func NewWithClient(auth aws.Auth, region aws.Region, httpClient *http.Client) *EB { + return &EB{auth, region, httpClient} +} + +func (eb *EB) query(params map[string]string, resp interface{}) error { + params["Version"] = APIVersion + params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339) + + endpoint, err := url.Parse(eb.Region.EBEndpoint) + if err != nil { + return err + } + + sign(eb.Auth, "GET", "/", params, endpoint.Host) + endpoint.RawQuery = multimap(params).Encode() + r, err := eb.httpClient.Get(endpoint.String()) + + if err != nil { + return err + } + defer r.Body.Close() + if r.StatusCode > 200 { + return buildError(r) + } + + decoder := xml.NewDecoder(r.Body) + decodedBody := decoder.Decode(resp) + + return decodedBody +} + +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.StatusCode = r.StatusCode + if err.Message == "" { + err.Message = r.Status + } + return &err +} + +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 +} + +func makeParams(action string) map[string]string { + params := make(map[string]string) + params["Action"] = action + return params +} + +// ---------------------------------------------------------------------------- +// EB objects + +type S3Location struct { + S3Bucket string + S3Key string +} + +type ConfigurationOptionSetting struct { + Namespace string + OptionName string + Value string +} + +type SourceConfiguration struct { + ApplicationName string + TemplateName string +} + +type OptionSpecification struct { + Namespace string + OptionName string +} + +type Tag struct { + Key string `xml:"Key"` + Value string `xml:"Value"` +} + +type EnvironmentTier struct { + Name string + Type string + Version string +} +type Listener struct { + Port int + Protocol string +} +type LoadBalancerDescription struct { + Domain string + Listeners []Listener + LoadBalancerName string +} + +//http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_EnvironmentResourcesDescription.html +type EnvironmentResourcesDescription struct { + LoadBalancer LoadBalancerDescription +} + +type AutoScalingGroup struct { + Name string +} +type Instance struct { + Id string +} +type LaunchConfiguration struct { + Name string +} +type LoadBalancer struct { + Name string +} +type Queue struct { + Name string + URL string +} +type Trigger struct { + Name string +} + +// Bad amazon! this is going to get confusing... +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_EnvironmentResourceDescription.html +type EnvironmentResourceDescription struct { + AutoScalingGroups []AutoScalingGroup `xml:"AutoScalingGroups>member"` + EnvironmentName string `xml:"EnvironmentName"` + Instances []Instance `xml:"Instances>member"` + LaunchConfigurations []LaunchConfiguration `xml:"LaunchConfigurations>member"` + LoadBalancers []LoadBalancer `xml:"LoadBalancers>member"` + Queues []Queue `xml:"Queues>member"` + Triggers []Trigger `xml:"Triggers>member"` +} + +type EnvironmentDescription struct { + ApplicationName string + CNAME string + DateCreated string + DateUpdated string + Description string + EndpointURL string + EnvironmentId string + EnvironmentName string + Health string + Resources []EnvironmentResourcesDescription + SolutionStackName string + Status string + TemplateName string + Tier EnvironmentTier + VersionLabel string +} + +type EventDescription struct { + ApplicationName string + EnvironmentName string + EventDate string + Message string + RequestId string + Severity string + TemplateName string + VersionLabel string +} + +type ApplicationDescription struct { + ApplicationName string `xml:"ApplicationName"` + ConfigurationTemplates []string `xml:"ConfigurationTemplates>member"` + DateCreated string `xml:"DateCreated"` + DateUpdated string `xml:"DateUpdated"` + Description string `xml:"Description"` + Versions []string `xml:"Versions>member"` +} + +type ApplicationVersionDescription struct { + ApplicationName string `xml:"ApplicationName"` + DateCreated string `xml:"DateCreated"` + DateUpdated string `xml:"DateUpdated"` + Description string `xml:"Description"` + SourceBundle S3Location `xml:"SourceBundle"` + VersionLabel string `xml:"VersionLabel"` +} + +type OptionRestrictionRegex struct { + Label string + Pattern string +} + +type ConfigurationOptionDescription struct { + ChangeSeverity string + DefaultValue string + MaxLength int + MaxValue int + MinValue int + Name string + Namespace string + Regex OptionRestrictionRegex + UserDefined bool + ValueOptions []string + ValueType string +} + +type ConfigurationSettingsDescription struct { + SolutionStackName string `xml:"SolutionStackName"` + OptionSettings []ConfigurationOptionSetting `xml:"OptionSettings>member"` + Description string `xml:"Description"` + ApplicationName string `xml:"ApplicationName"` + DateCreated string `xml:"DateCreated"` + DateUpdated string `xml:"DateUpdated"` + TemplateName string `xml:"TemplateName"` +} + +// ---------------------------------------------------------------------------- +// Create + +// The CreateApplication request parameters +type CreateApplication struct { + ApplicationName string + Description string +} + +type CreateApplicationResp struct { + Application ApplicationDescription `xml:"CreateApplicationResult>Application"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CreateApplication(options *CreateApplication) (resp *CreateApplicationResp, err error) { + params := makeParams("CreateApplication") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + resp = &CreateApplicationResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateApplicationVersion.html + +// The CreateApplicationVersion request parameters +type CreateApplicationVersion struct { + ApplicationName string + AutoCreateApplication bool + Description string + SourceBundle S3Location + VersionLabel string +} + +type CreateApplicationVersionResp struct { + ApplicationVersion ApplicationVersionDescription `xml:"CreateApplicationVersionResult>ApplicationVersion"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CreateApplicationVersion(options *CreateApplicationVersion) (resp *CreateApplicationVersionResp, err error) { + params := makeParams("CreateApplicationVersion") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + if options.AutoCreateApplication { + params["AutoCreateApplication"] = "true" + } + params["SourceBundle.S3Bucket"] = options.SourceBundle.S3Bucket + params["SourceBundle.S3Key"] = options.SourceBundle.S3Key + params["VersionLabel"] = options.VersionLabel + + resp = &CreateApplicationVersionResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// CreateConfigurationTemplate + +type CreateConfigurationTemplate struct { + ApplicationName string + Description string + EnvironmentId string + OptionSettings []ConfigurationOptionSetting + SolutionStackName string + SourceConfiguration SourceConfiguration + TemplateName string +} + +type CreateConfigurationTemplateResp struct { + ApplicationName string `xml:"CreateConfigurationTemplateResult>ApplicationName"` + DateCreated string `xml:"CreateConfigurationTemplateResult>DateCreated"` + DateUpdated string `xml:"CreateConfigurationTemplateResult>DateUpdated"` + DeploymentStatus string `xml:"CreateConfigurationTemplateResult>DeploymentStatus"` + Description string `xml:"CreateConfigurationTemplateResult>Description"` + EnvironmentName string `xml:"CreateConfigurationTemplateResult>EnvironmentName"` + OptionSettings []ConfigurationOptionSetting `xml:"CreateConfigurationTemplateResult>OptionSettings>member"` + SolutionStackName string `xml:"CreateConfigurationTemplateResult>SolutionStackName"` + TemplateName string `xml:"CreateConfigurationTemplateResult>TemplateName"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CreateConfigurationTemplate(options *CreateConfigurationTemplate) (resp *CreateConfigurationTemplateResp, err error) { + params := makeParams("CreateConfigurationTemplate") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + params["EnvironmentId"] = options.EnvironmentId + + for i, v := range options.OptionSettings { + params["OptionSettings.member."+strconv.Itoa(i+1)+"Namespace"] = v.Namespace + params["OptionSettings.member."+strconv.Itoa(i+1)+"OptionName"] = v.OptionName + params["OptionSettings.member."+strconv.Itoa(i+1)+"Value"] = v.Value + } + + params["SolutionStackName"] = options.SolutionStackName + params["SourceConfiguration.ApplicationName"] = options.SourceConfiguration.ApplicationName + params["SourceConfiguration.TemplateName"] = options.SourceConfiguration.TemplateName + params["TemplateName"] = options.TemplateName + + resp = &CreateConfigurationTemplateResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// CreateEnvironment +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateEnvironment.html + +type CreateEnvironment struct { + ApplicationName string + CNAMEPrefix string + Description string + EnvironmentName string + OptionSettings []ConfigurationOptionSetting + OptionsToRemove []OptionSpecification + SolutionStackName string + Tags []Tag + TemplateName string + Tier EnvironmentTier + VersionLabel string +} + +type CreateEnvironmentResp struct { + ApplicationName string `xml:"CreateEnvironmentResult>ApplicationName"` + CNAME string `xml:"CreateEnvironmentResult>CNAME"` + DateCreated string `xml:"CreateEnvironmentResult>DateCreated"` + DateUpdated string `xml:"CreateEnvironmentResult>DateUpdated"` + Description string `xml:"CreateEnvironmentResult>Description"` + EndpointURL string `xml:"CreateEnvironmentResult>EndpointURL"` + EnvironmentId string `xml:"CreateEnvironmentResult>EnvironmentId"` + EnvironmentName string `xml:"CreateEnvironmentResult>EnvironmentName"` + Health string `xml:"CreateEnvironmentResult>Health"` + Resources EnvironmentResourcesDescription `xml:"CreateEnvironmentResult>Resources"` + SolutionStackName string `xml:"CreateEnvironmentResult>SolutionStackName"` + Status string `xml:"CreateEnvironmentResult>Status"` + TemplateName string `xml:"CreateEnvironmentResult>TemplateName"` + Tier EnvironmentTier `xml:"CreateEnvironmentResult>Tier"` + VersionLabel string `xml:"CreateEnvironmentResult>VersionLabel"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CreateEnvironment(options *CreateEnvironment) (resp *CreateEnvironmentResp, err error) { + params := makeParams("CreateEnvironment") + + params["ApplicationName"] = options.ApplicationName + params["CNAMEPrefix"] = options.CNAMEPrefix + params["Description"] = options.Description + params["EnvironmentName"] = options.EnvironmentName + + for i, v := range options.OptionSettings { + params["OptionSettings.member."+strconv.Itoa(i+1)+"Namespace"] = v.Namespace + params["OptionSettings.member."+strconv.Itoa(i+1)+"OptionName"] = v.OptionName + params["OptionSettings.member."+strconv.Itoa(i+1)+"Value"] = v.Value + } + + for i, v := range options.OptionsToRemove { + params["OptionsToRemove.member."+strconv.Itoa(i+1)+"Namespace"] = v.Namespace + params["OptionsToRemove.member."+strconv.Itoa(i+1)+"OptionName"] = v.OptionName + + } + params["SolutionStackName"] = options.SolutionStackName + for i, v := range options.Tags { + params["Tags.member."+strconv.Itoa(i+1)+"Key"] = v.Key + params["Tags.member."+strconv.Itoa(i+1)+"Value"] = v.Value + + } + params["TemplateName"] = options.TemplateName + + params["Tier.Name"] = options.Tier.Name + params["Tier.Type"] = options.Tier.Type + params["Tier.Version"] = options.Tier.Version + + params["VersionLabel"] = options.VersionLabel + + resp = &CreateEnvironmentResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// CreateStorageLocation + +type CreateStorageLocationResp struct { + S3Bucket string `xml:"CreateStorageLocationResult>S3Bucket"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CreateStorageLocation() (resp *CreateStorageLocationResp, err error) { + params := makeParams("CreateStorageLocation") + + resp = &CreateStorageLocationResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- +// CheckDNSAvailability + +type CheckDNSAvailability struct { + CNAMEPrefix string +} + +type CheckDNSAvailabilityResp struct { + FullyQualifiedCNAME string `xml:"CheckDNSAvailabilityResult>FullyQualifiedCNAME"` + Available bool `xml:"CheckDNSAvailabilityResult>Available"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) CheckDNSAvailability(options *CheckDNSAvailability) (resp *CheckDNSAvailabilityResp, err error) { + params := makeParams("CheckDNSAvailability") + + params["CNAMEPrefix"] = options.CNAMEPrefix + resp = &CheckDNSAvailabilityResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- +// Delete + +// The DeleteApplication request parameters +type DeleteApplication struct { + ApplicationName string + TerminateEnvByForce bool +} + +func (eb *EB) DeleteApplication(options *DeleteApplication) (resp *SimpleResp, err error) { + params := makeParams("DeleteApplication") + + params["ApplicationName"] = options.ApplicationName + + if options.TerminateEnvByForce { + params["TerminateEnvByForce"] = "true" + } + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// DeleteApplicationVersion +type DeleteApplicationVersion struct { + ApplicationName string + DeleteSourceBundle bool + VersionLabel string +} + +func (eb *EB) DeleteApplicationVersion(options *DeleteApplicationVersion) (resp *SimpleResp, err error) { + params := makeParams("DeleteApplicationVersion") + + params["ApplicationName"] = options.ApplicationName + params["VersionLabel"] = options.VersionLabel + + if options.DeleteSourceBundle { + params["DeleteSourceBundle"] = "true" + } + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +//DeleteConfigurationTemplate + +type DeleteConfigurationTemplate struct { + ApplicationName string + TemplateName string +} + +func (eb *EB) DeleteConfigurationTemplate(options *DeleteConfigurationTemplate) (resp *SimpleResp, err error) { + params := makeParams("DeleteConfigurationTemplate") + + params["ApplicationName"] = options.ApplicationName + params["TemplateName"] = options.TemplateName + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// DeleteEnvironmentConfiguration +type DeleteEnvironmentConfiguration struct { + ApplicationName string + EnvironmentName string +} + +func (eb *EB) DeleteEnvironmentConfiguration(options *DeleteEnvironmentConfiguration) (resp *SimpleResp, err error) { + params := makeParams("DeleteEnvironmentConfiguration") + + params["ApplicationName"] = options.ApplicationName + params["EnvironmentName"] = options.EnvironmentName + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- +// Describe + +// DescribeApplicationVersions + +type DescribeApplicationVersions struct { + ApplicationName string + VersionLabels []string +} + +type DescribeApplicationVersionsResp struct { + ApplicationVersions []ApplicationVersionDescription `xml:"DescribeApplicationVersionsResult>ApplicationVersions>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeApplicationVersions(options *DescribeApplicationVersions) (resp *DescribeApplicationVersionsResp, err error) { + params := makeParams("DescribeApplicationVersions") + + params["ApplicationName"] = options.ApplicationName + for i, v := range options.VersionLabels { + params["VersionLabels.member."+strconv.Itoa(i+1)] = v + + } + + resp = &DescribeApplicationVersionsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// DescribeApplications + +type DescribeApplications struct { + ApplicationNames []string +} + +type DescribeApplicationsResp struct { + Applications []ApplicationDescription `xml:"DescribeApplicationsResult>Applications>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeApplications(options *DescribeApplications) (resp *DescribeApplicationsResp, err error) { + params := makeParams("DescribeApplications") + + for i, v := range options.ApplicationNames { + params["ApplicationNames.member."+strconv.Itoa(i+1)] = v + } + + resp = &DescribeApplicationsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// DescribeConfigurationOptions + +type DescribeConfigurationOptions struct { + ApplicationName string + EnvironmentName string + Options []OptionSpecification + SolutionStackName string + TemplateName string +} + +type DescribeConfigurationOptionsResp struct { + Options []ConfigurationOptionDescription `xml:"DescribeConfigurationOptionsResult>Options>member"` + SolutionStackName string `xml:"DescribeConfigurationOptionsResult>SolutionStackName"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeConfigurationOptions(options *DescribeConfigurationOptions) (resp *DescribeConfigurationOptionsResp, err error) { + params := makeParams("DescribeConfigurationOptions") + + params["ApplicationName"] = options.ApplicationName + params["EnvironmentName"] = options.EnvironmentName + for i, v := range options.Options { + params["Options.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["Options.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + } + params["SolutionStackName"] = options.SolutionStackName + params["TemplateName"] = options.TemplateName + + resp = &DescribeConfigurationOptionsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// DescribeConfigurationSettings + +type DescribeConfigurationSettings struct { + ApplicationName string + EnvironmentName string + TemplateName string +} + +type DescribeConfigurationSettingsResp struct { + ConfigurationSettings []ConfigurationSettingsDescription `xml:"DescribeConfigurationSettingsResult>ConfigurationSettings>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeConfigurationSettings(options *DescribeConfigurationSettings) (resp *DescribeConfigurationSettingsResp, err error) { + params := makeParams("DescribeConfigurationSettings") + + params["ApplicationName"] = options.ApplicationName + params["EnvironmentName"] = options.EnvironmentName + params["TemplateName"] = options.TemplateName + + resp = &DescribeConfigurationSettingsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// DescribeEnvironmentResources + +type DescribeEnvironmentResources struct { + EnvironmentId string + EnvironmentName string +} + +type DescribeEnvironmentResourcesResp struct { + EnvironmentResources []EnvironmentResourceDescription `xml:"DescribeEnvironmentResourcesResult>EnvironmentResources"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeEnvironmentResources(options *DescribeEnvironmentResources) (resp *DescribeEnvironmentResourcesResp, err error) { + params := makeParams("DescribeEnvironmentResources") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + + resp = &DescribeEnvironmentResourcesResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// DescribeEnvironments + +type DescribeEnvironments struct { + ApplicationName string + EnvironmentIds []string + EnvironmentNames []string + IncludeDeleted bool + IncludedDeletedBackTo string + VersionLabel string +} + +type DescribeEnvironmentsResp struct { + Environments []EnvironmentDescription `xml:"DescribeEnvironmentsResult>Environments>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeEnvironments(options *DescribeEnvironments) (resp *DescribeEnvironmentsResp, err error) { + params := makeParams("DescribeEnvironments") + + params["ApplicationName"] = options.ApplicationName + for i, v := range options.EnvironmentIds { + params["EnvironmentIds.member."+strconv.Itoa(i+1)] = v + } + for i, v := range options.EnvironmentNames { + params["EnvironmentNames.member."+strconv.Itoa(i+1)] = v + } + if options.IncludeDeleted { + params["IncludeDeleted"] = "true" + } + params["IncludedDeletedBackTo"] = options.IncludedDeletedBackTo + params["VersionLabel"] = options.VersionLabel + + resp = &DescribeEnvironmentsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// DescribeEvents + +type DescribeEvents struct { + ApplicationName string + EndTime string + EnvironmentId string + EnvironmentName string + MaxRecords string + NextToken string + RequestId string + Severity string + StartTime string + TemplateName string + VersionLabel string +} + +type DescribeEventsResp struct { + Events []EventDescription `xml:"DescribeEventsResult>Events>member"` + NextToken string `xml:"DescribeEventsResult>NextToken"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) DescribeEvents(options *DescribeEvents) (resp *DescribeEventsResp, err error) { + params := makeParams("DescribeEvents") + + params["ApplicationName"] = options.ApplicationName + params["EndTime"] = options.EndTime + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + params["MaxRecords"] = options.MaxRecords + params["NextToken"] = options.NextToken + params["RequestId"] = options.RequestId + params["Severity"] = options.Severity + params["StartTime"] = options.StartTime + params["TemplateName"] = options.TemplateName + params["VersionLabel"] = options.VersionLabel + + resp = &DescribeEventsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- +// List + +type SolutionStackDescription struct { + PermittedFileTypes []string + SolutionStackName string +} + +type ListAvailableSolutionStacksResp struct { + SolutionStackDetails []SolutionStackDescription `xml:"ListAvailableSolutionStacksResult>SolutionStackDetails"` + SolutionStacks []string `xml:"ListAvailableSolutionStacksResult>SolutionStacks>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) ListAvailableSolutionStacks() (resp *ListAvailableSolutionStacksResp, err error) { + params := makeParams("ListAvailableSolutionStacks") + + resp = &ListAvailableSolutionStacksResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- +// Rebuild + +// RebuildEnvironment + +type RebuildEnvironment struct { + EnvironmentId string + EnvironmentName string +} + +func (eb *EB) RebuildEnvironment(options *RebuildEnvironment) (resp *SimpleResp, err error) { + params := makeParams("RebuildEnvironment") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// RequestEnvironmentInfo + +type RequestEnvironmentInfo struct { + EnvironmentId string + EnvironmentName string + InfoType string +} + +func (eb *EB) RequestEnvironmentInfo(options *RequestEnvironmentInfo) (resp *SimpleResp, err error) { + params := makeParams("RequestEnvironmentInfo") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + params["InfoType"] = options.InfoType + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// RestartAppServer + +type RestartAppServer struct { + EnvironmentId string + EnvironmentName string +} + +func (eb *EB) RestartAppServer(options *RestartAppServer) (resp *SimpleResp, err error) { + params := makeParams("RestartAppServer") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// RetrieveEnvironmentInfo + +type EnvironmentInfoDescription struct { + Ec2InstanceId string `xml:"Ec2InstanceId"` + InfoType string `xml:"InfoType"` + Message string `xml:"Message"` + SampleTimestamp string `xml:"SampleTimestamp"` +} + +type RetrieveEnvironmentInfo struct { + EnvironmentId string + EnvironmentName string + InfoType string +} + +type RetrieveEnvironmentInfoResp struct { + EnvironmentInfo []EnvironmentInfoDescription `xml:"RetrieveEnvironmentInfoResult>EnvironmentInfo>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) RetrieveEnvironmentInfo(options *RetrieveEnvironmentInfo) (resp *RetrieveEnvironmentInfoResp, err error) { + params := makeParams("RetrieveEnvironmentInfo") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + params["InfoType"] = options.InfoType + + resp = &RetrieveEnvironmentInfoResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// SwapEnvironmentCNAMEs + +type SwapEnvironmentCNAMEs struct { + DestinationEnvironmentId string + DestinationEnvironmentName string + SourceEnvironmentId string + SourceEnvironmentName string +} + +func (eb *EB) SwapEnvironmentCNAMEs(options *SwapEnvironmentCNAMEs) (resp *SimpleResp, err error) { + params := makeParams("SwapEnvironmentCNAMEs") + + params["DestinationEnvironmentId"] = options.DestinationEnvironmentId + params["DestinationEnvironmentName"] = options.DestinationEnvironmentName + params["SourceEnvironmentId"] = options.SourceEnvironmentId + params["SourceEnvironmentName"] = options.SourceEnvironmentName + + resp = &SimpleResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- +// Terminate + +type TerminateEnvironment struct { + EnvironmentId string + EnvironmentName string + TerminateResources bool +} + +type TerminateEnvironmentResp struct { + ApplicationName string `xml:"TerminateEnvironmentResult>ApplicationName"` + CNAME string `xml:"TerminateEnvironmentResult>CNAME"` + DateCreated string `xml:"TerminateEnvironmentResult>DateCreated"` + DateUpdated string `xml:"TerminateEnvironmentResult>DateUpdated"` + Description string `xml:"TerminateEnvironmentResult>Description"` + EndpointURL string `xml:"TerminateEnvironmentResult>EndpointURL"` + EnvironmentId string `xml:"TerminateEnvironmentResult>EnvironmentId"` + EnvironmentName string `xml:"TerminateEnvironmentResult>EnvironmentName"` + Health string `xml:"TerminateEnvironmentResult>Health"` + Resources EnvironmentResourcesDescription `xml:"TerminateEnvironmentResult>Resources"` + SolutionStackName string `xml:"TerminateEnvironmentResult>SolutionStackName"` + Status string `xml:"TerminateEnvironmentResult>Status"` + TemplateName string `xml:"TerminateEnvironmentResult>TemplateName"` + Tier EnvironmentTier `xml:"TerminateEnvironmentResult>Tier"` + VersionLabel string `xml:"TerminateEnvironmentResult>VersionLabel"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) TerminateEnvironment(options *TerminateEnvironment) (resp *TerminateEnvironmentResp, err error) { + params := makeParams("TerminateEnvironment") + + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + if !options.TerminateResources { + params["TerminateResources"] = "false" + } else { + params["TerminateResources"] = "true" + } + + resp = &TerminateEnvironmentResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- +// Update + +// UpdateApplication + +type UpdateApplication struct { + ApplicationName string + Description string +} + +type UpdateApplicationResp struct { + Application ApplicationDescription `xml:"UpdateApplicationResult>Application"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) UpdateApplication(options *UpdateApplication) (resp *UpdateApplicationResp, err error) { + params := makeParams("UpdateApplication") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + + resp = &UpdateApplicationResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// UpdateApplicationVersion + +type UpdateApplicationVersion struct { + ApplicationName string + Description string + VersionLabel string +} + +type UpdateApplicationVersionResp struct { + ApplicationVersion ApplicationVersionDescription `xml:"UpdateApplicationVersionResult>ApplicationVersion"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) UpdateApplicationVersion(options *UpdateApplicationVersion) (resp *UpdateApplicationVersionResp, err error) { + params := makeParams("UpdateApplicationVersion") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + params["VersionLabel"] = options.VersionLabel + + resp = &UpdateApplicationVersionResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// UpdateConfigurationTemplate + +type UpdateConfigurationTemplate struct { + ApplicationName string + Description string + OptionSettings []ConfigurationOptionSetting + OptionsToRemove []OptionSpecification + TemplateName string +} + +type UpdateConfigurationTemplateResp struct { + ApplicationName string `xml:"UpdateConfigurationTemplateResult>ApplicationName"` + DateCreated string `xml:"UpdateConfigurationTemplateResult>DateCreated"` + DateUpdated string `xml:"UpdateConfigurationTemplateResult>DateUpdated"` + DeploymentStatus string `xml:"UpdateConfigurationTemplateResult>DeploymentStatus"` + Description string `xml:"UpdateConfigurationTemplateResult>Description"` + EnvironmentName string `xml:"UpdateConfigurationTemplateResult>EnvironmentName"` + OptionSettings []ConfigurationOptionSetting `xml:"UpdateConfigurationTemplateResult>OptionSettings>member"` + SolutionStackName string `xml:"UpdateConfigurationTemplateResult>SolutionStackName"` + TemplateName string `xml:"UpdateConfigurationTemplateResult>TemplateName"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) UpdateConfigurationTemplate(options *UpdateConfigurationTemplate) (resp *UpdateConfigurationTemplateResp, err error) { + params := makeParams("UpdateConfigurationTemplate") + + params["ApplicationName"] = options.ApplicationName + params["Description"] = options.Description + for i, v := range options.OptionSettings { + params["OptionSettings.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["OptionSettings.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + params["OptionSettings.member."+strconv.Itoa(i+1)+".Value"] = v.Value + } + for i, v := range options.OptionsToRemove { + params["OptionsToRemove.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["OptionsToRemove.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + } + params["TemplateName"] = options.TemplateName + + resp = &UpdateConfigurationTemplateResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// UpdateEnvironment + +type UpdateEnvironment struct { + Description string + EnvironmentId string + EnvironmentName string + OptionSettings []ConfigurationOptionSetting + OptionsToRemove []OptionSpecification + TemplateName string + Tier EnvironmentTier + VersionLabel string +} + +type UpdateEnvironmentResp struct { + ApplicationName string `xml:"UpdateEnvironmentResult>ApplicationName"` + CNAME string `xml:"UpdateEnvironmentResult>CNAME"` + DateCreated string `xml:"UpdateEnvironmentResult>DateCreated"` + DateUpdated string `xml:"UpdateEnvironmentResult>DateUpdated"` + Description string `xml:"UpdateEnvironmentResult>Description"` + EndpointURL string `xml:"UpdateEnvironmentResult>EndpointURL"` + EnvironmentId string `xml:"UpdateEnvironmentResult>EnvironmentId"` + EnvironmentName string `xml:"UpdateEnvironmentResult>EnvironmentName"` + Health string `xml:"UpdateEnvironmentResult>Health"` + Resources EnvironmentResourceDescription `xml:"UpdateEnvironmentResult>Resources"` + SolutionStackName string `xml:"UpdateEnvironmentResult>SolutionStackName"` + Status string `xml:"UpdateEnvironmentResult>Status"` + TemplateName string `xml:"UpdateEnvironmentResult>TemplateName"` + Tier EnvironmentTier `xml:"UpdateEnvironmentResult>Tier"` + VersionLabel string `xml:"UpdateEnvironmentResult>VersionLabel"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) UpdateEnvironment(options *UpdateEnvironment) (resp *UpdateEnvironmentResp, err error) { + params := makeParams("UpdateEnvironment") + + params["Description"] = options.Description + params["EnvironmentId"] = options.EnvironmentId + params["EnvironmentName"] = options.EnvironmentName + params["TemplateName"] = options.TemplateName + params["VersionLabel"] = options.VersionLabel + + for i, v := range options.OptionSettings { + params["OptionSettings.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["OptionSettings.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + params["OptionSettings.member."+strconv.Itoa(i+1)+".Value"] = v.Value + } + for i, v := range options.OptionsToRemove { + params["OptionsToRemove.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["OptionsToRemove.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + } + params["Tier.Name"] = options.Tier.Name + params["Tier.Type"] = options.Tier.Type + params["Tier.Version"] = options.Tier.Version + + resp = &UpdateEnvironmentResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- +// Validate + +// ValidateConfigurationSettings + +type ValidateConfigurationSettings struct { + ApplicationName string + EnvironmentName string + OptionSettings []ConfigurationOptionSetting + TemplateName string +} + +type ValidationMessage struct { + Message string + Namespace string + OptionName string + Severity string +} + +type ValidateConfigurationSettingsResp struct { + Messages []ValidationMessage `xml:"ValidateConfigurationSettingsResult>Messages>member"` + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +func (eb *EB) ValidateConfigurationSettings(options *ValidateConfigurationSettings) (resp *ValidateConfigurationSettingsResp, err error) { + params := makeParams("ValidateConfigurationSettings") + + params["ApplicationName"] = options.ApplicationName + params["EnvironmentName"] = options.EnvironmentName + params["TemplateName"] = options.TemplateName + + for i, v := range options.OptionSettings { + params["OptionSettings.member."+strconv.Itoa(i+1)+".Namespace"] = v.Namespace + params["OptionSettings.member."+strconv.Itoa(i+1)+".OptionName"] = v.OptionName + params["OptionSettings.member."+strconv.Itoa(i+1)+".Value"] = v.Value + } + + resp = &ValidateConfigurationSettingsResp{} + + err = eb.query(params, resp) + + if err != nil { + resp = nil + } + + return +} + +// ---------------------------------------------------------------------------- +// Responses + +type SimpleResp struct { + RequestId string `xml:"ResponseMetadata>RequestId"` +} + +type xmlErrors struct { + Errors []Error `xml:"Error"` +} + +// Error encapsulates an elb error. +type Error struct { + // HTTP status code of the error. + StatusCode int + + // AWS code of the error. + Code string + + // Message explaining the error. + Message string +} + +func (e *Error) Error() string { + var prefix string + if e.Code != "" { + prefix = e.Code + ": " + } + if prefix == "" && e.StatusCode > 0 { + prefix = strconv.Itoa(e.StatusCode) + ": " + } + return prefix + e.Message +} diff --git a/eb/eb_test.go b/eb/eb_test.go new file mode 100644 index 00000000..c41a437b --- /dev/null +++ b/eb/eb_test.go @@ -0,0 +1,728 @@ +package eb_test + +import ( + "github.com/mitchellh/goamz/aws" + "github.com/mitchellh/goamz/eb" + "github.com/mitchellh/goamz/testutil" + . "github.com/motain/gocheck" + "testing" +) + +func Test(t *testing.T) { + TestingT(t) +} + +type S struct { + eb *eb.EB +} + +var _ = Suite(&S{}) + +var testServer = testutil.NewHTTPServer() + +func (s *S) SetUpSuite(c *C) { + testServer.Start() + auth := aws.Auth{"abc", "123", ""} + s.eb = eb.NewWithClient(auth, aws.Region{EBEndpoint: testServer.URL}, testutil.DefaultClient) +} + +func (s *S) TearDownTest(c *C) { + testServer.Flush() +} + +func (s *S) TestCreateApplication(c *C) { + testServer.Response(200, nil, CreateApplicationExample) + + options := eb.CreateApplication{ + ApplicationName: "SampleApp", + Description: "Sample Description", + } + + resp, err := s.eb.CreateApplication(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CreateApplication"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"Sample Description"}) + c.Assert(err, IsNil) + c.Assert(resp.Application.ApplicationName, Equals, "SampleApp") + c.Assert(resp.Application.ConfigurationTemplates, DeepEquals, []string{"Default"}) + c.Assert(resp.Application.DateCreated, Equals, "2010-11-16T23:09:20.256Z") + c.Assert(resp.Application.DateUpdated, Equals, "2010-11-16T23:09:20.256Z") + c.Assert(resp.Application.Description, Equals, "Sample Description") + c.Assert(resp.RequestId, Equals, "8b00e053-f1d6-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestCheckDNSAvailability(c *C) { + testServer.Response(200, nil, CheckDNSAvailabilityExample) + + options := eb.CheckDNSAvailability{ + CNAMEPrefix: "sampleapplication", + } + + resp, err := s.eb.CheckDNSAvailability(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CheckDNSAvailability"}) + c.Assert(req.Form["CNAMEPrefix"], DeepEquals, []string{"sampleapplication"}) + c.Assert(err, IsNil) + c.Assert(resp.FullyQualifiedCNAME, Equals, "sampleapplication.elasticbeanstalk.amazonaws.com") + c.Assert(resp.Available, Equals, true) + c.Assert(resp.RequestId, Equals, "12f6701f-f1d6-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestCreateApplicationVersion(c *C) { + testServer.Response(200, nil, CreateApplicationVersionExample) + + options := eb.CreateApplicationVersion{ + ApplicationName: "SampleApp", + VersionLabel: "Version1", + Description: "description", + AutoCreateApplication: true, + SourceBundle: eb.S3Location{ + S3Bucket: "amazonaws.com", + S3Key: "sample.war", + }, + } + + resp, err := s.eb.CreateApplicationVersion(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CreateApplicationVersion"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["VersionLabel"], DeepEquals, []string{"Version1"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"description"}) + c.Assert(req.Form["AutoCreateApplication"], DeepEquals, []string{"true"}) + c.Assert(req.Form["SourceBundle.S3Bucket"], DeepEquals, []string{"amazonaws.com"}) + c.Assert(req.Form["SourceBundle.S3Key"], DeepEquals, []string{"sample.war"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationVersion.ApplicationName, Equals, "SampleApp") + c.Assert(resp.ApplicationVersion.DateCreated, Equals, "2010-11-17T03:21:59.161Z") + c.Assert(resp.ApplicationVersion.DateUpdated, Equals, "2010-11-17T03:21:59.161Z") + c.Assert(resp.ApplicationVersion.Description, Equals, "description") + c.Assert(resp.ApplicationVersion.SourceBundle.S3Bucket, Equals, "amazonaws.com") + c.Assert(resp.ApplicationVersion.SourceBundle.S3Key, Equals, "sample.war") + c.Assert(resp.ApplicationVersion.VersionLabel, Equals, "Version1") + c.Assert(resp.RequestId, Equals, "d653efef-f1f9-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestCreateConfigurationTemplate(c *C) { + testServer.Response(200, nil, CreateConfigurationTemplateExample) + + options := eb.CreateConfigurationTemplate{ + ApplicationName: "SampleApp", + Description: "ConfigTemplateDescription", + EnvironmentId: "", + OptionSettings: []eb.ConfigurationOptionSetting{}, + SolutionStackName: "32bit Amazon Linux running Tomcat 7", + SourceConfiguration: eb.SourceConfiguration{}, + TemplateName: "AppTemplate", + } + + resp, err := s.eb.CreateConfigurationTemplate(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CreateConfigurationTemplate"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"ConfigTemplateDescription"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{""}) + c.Assert(req.Form["SolutionStackName"], DeepEquals, []string{"32bit Amazon Linux running Tomcat 7"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"AppTemplate"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.DateCreated, Equals, "2010-11-17T03:48:19.640Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T03:48:19.640Z") + c.Assert(resp.Description, Equals, "ConfigTemplateDescription") + c.Assert(resp.OptionSettings[0].OptionName, Equals, "ImageId") + c.Assert(resp.OptionSettings[0].Value, Equals, "ami-f2f0069b") + c.Assert(resp.OptionSettings[0].Namespace, Equals, "aws:autoscaling:launchconfiguration") + c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.RequestId, Equals, "846cd905-f1fd-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestCreateEnvironment(c *C) { + testServer.Response(200, nil, CreateEnvironmentExample) + + options := eb.CreateEnvironment{ + ApplicationName: "SampleApp", + EnvironmentName: "SampleApp", + SolutionStackName: "32bit Amazon Linux running Tomcat 7", + Description: "EnvDescrip", + } + + resp, err := s.eb.CreateEnvironment(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CreateEnvironment"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["SolutionStackName"], DeepEquals, []string{"32bit Amazon Linux running Tomcat 7"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"EnvDescrip"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.DateCreated, Equals, "2010-11-17T03:59:33.520Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T03:59:33.520Z") + c.Assert(resp.Description, Equals, "EnvDescrip") + c.Assert(resp.EnvironmentId, Equals, "e-icsgecu3wf") + c.Assert(resp.EnvironmentName, Equals, "SampleApp") + c.Assert(resp.Health, Equals, "Grey") + c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.Status, Equals, "Deploying") + c.Assert(resp.VersionLabel, Equals, "Version1") + c.Assert(resp.RequestId, Equals, "15db925e-f1ff-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestCreateStorageLocation(c *C) { + testServer.Response(200, nil, CreateStorageLocationExample) + + resp, err := s.eb.CreateStorageLocation() + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"CreateStorageLocation"}) + c.Assert(err, IsNil) + c.Assert(resp.S3Bucket, Equals, "elasticbeanstalk-us-east-1-780612358023") +} + +func (s *S) TestDeleteApplication(c *C) { + testServer.Response(200, nil, DeleteApplicationExample) + + options := eb.DeleteApplication{ + ApplicationName: "foobar", + } + + resp, err := s.eb.DeleteApplication(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteApplication"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"foobar"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "1f155abd-f1d7-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDeleteApplicationVersion(c *C) { + testServer.Response(200, nil, DeleteApplicationVersionExample) + + options := eb.DeleteApplicationVersion{ + ApplicationName: "SampleApp", + VersionLabel: "First Release", + } + + resp, err := s.eb.DeleteApplicationVersion(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteApplicationVersion"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["VersionLabel"], DeepEquals, []string{"First Release"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "58dc7339-f272-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDeleteConfigurationTemplate(c *C) { + testServer.Response(200, nil, DeleteConfigurationTemplateExample) + + options := eb.DeleteConfigurationTemplate{ + ApplicationName: "SampleApp", + TemplateName: "SampleAppTemplate", + } + + resp, err := s.eb.DeleteConfigurationTemplate(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteConfigurationTemplate"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"SampleAppTemplate"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "af9cf1b6-f25e-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDeleteEnvironmentConfiguration(c *C) { + testServer.Response(200, nil, DeleteEnvironmentConfigurationExample) + + options := eb.DeleteEnvironmentConfiguration{ + ApplicationName: "SampleApp", + EnvironmentName: "SampleAppEnv", + } + + resp, err := s.eb.DeleteEnvironmentConfiguration(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DeleteEnvironmentConfiguration"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppEnv"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "fdf76507-f26d-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDescribeApplicationVersions(c *C) { + testServer.Response(200, nil, DescribeApplicationVersionsExample) + + options := eb.DescribeApplicationVersions{ + ApplicationName: "SampleApp", + } + + resp, err := s.eb.DescribeApplicationVersions(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeApplicationVersions"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationVersions[0].ApplicationName, Equals, "SampleApp") + c.Assert(resp.ApplicationVersions[0].DateCreated, Equals, "2010-11-17T03:21:59.161Z") + c.Assert(resp.ApplicationVersions[0].DateUpdated, Equals, "2010-11-17T03:21:59.161Z") + c.Assert(resp.ApplicationVersions[0].Description, Equals, "description") + c.Assert(resp.ApplicationVersions[0].SourceBundle.S3Bucket, Equals, "amazonaws.com") + c.Assert(resp.ApplicationVersions[0].SourceBundle.S3Key, Equals, "sample.war") + c.Assert(resp.ApplicationVersions[0].VersionLabel, Equals, "Version1") + c.Assert(resp.RequestId, Equals, "773cd80a-f26c-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDescribeApplications(c *C) { + testServer.Response(200, nil, DescribeApplicationsExample) + + options := eb.DescribeApplications{ + ApplicationNames: []string{"SampleApplication"}, + } + + resp, err := s.eb.DescribeApplications(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeApplications"}) + c.Assert(req.Form["ApplicationNames.member.1"], DeepEquals, []string{"SampleApplication"}) + c.Assert(err, IsNil) + c.Assert(resp.Applications[0].ApplicationName, Equals, "SampleApplication") + c.Assert(resp.Applications[0].DateCreated, Equals, "2010-11-16T20:20:51.974Z") + c.Assert(resp.Applications[0].DateUpdated, Equals, "2010-11-16T20:20:51.974Z") + c.Assert(resp.Applications[0].Description, Equals, "Sample Description") + c.Assert(resp.Applications[0].ConfigurationTemplates[0], Equals, "Default") + c.Assert(resp.RequestId, Equals, "577c70ff-f1d7-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDescribeConfigurationOptions(c *C) { + testServer.Response(200, nil, DescribeConfigurationOptionsExample) + + options := eb.DescribeConfigurationOptions{ + ApplicationName: "SampleApp", + TemplateName: "default", + } + + resp, err := s.eb.DescribeConfigurationOptions(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeConfigurationOptions"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"default"}) + c.Assert(err, IsNil) + c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.Options[0].ChangeSeverity, Equals, "RestartEnvironment") + c.Assert(resp.Options[0].DefaultValue, Equals, "ami-6036c009") + c.Assert(resp.Options[0].MaxLength, Equals, 2000) + c.Assert(resp.Options[0].Name, Equals, "ImageId") + c.Assert(resp.Options[0].Namespace, Equals, "aws:autoscaling:launchconfiguration") + c.Assert(resp.Options[0].UserDefined, Equals, false) + c.Assert(resp.Options[0].ValueType, Equals, "Scalar") + c.Assert(resp.RequestId, Equals, "e8768900-f272-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDescribeConfigurationSettings(c *C) { + testServer.Response(200, nil, DescribeConfigurationSettingsExample) + + options := eb.DescribeConfigurationSettings{ + ApplicationName: "SampleApp", + TemplateName: "default", + } + + resp, err := s.eb.DescribeConfigurationSettings(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeConfigurationSettings"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"default"}) + c.Assert(err, IsNil) + c.Assert(resp.ConfigurationSettings[0].SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.ConfigurationSettings[0].OptionSettings[0].OptionName, Equals, "ImageId") + c.Assert(resp.ConfigurationSettings[0].OptionSettings[0].Value, Equals, "ami-f2f0069b") + c.Assert(resp.ConfigurationSettings[0].OptionSettings[0].Namespace, Equals, "aws:autoscaling:launchconfiguration") + c.Assert(resp.ConfigurationSettings[0].Description, Equals, "Default Configuration Template") + c.Assert(resp.ConfigurationSettings[0].ApplicationName, Equals, "SampleApp") + c.Assert(resp.ConfigurationSettings[0].TemplateName, Equals, "Default") + c.Assert(resp.ConfigurationSettings[0].DateCreated, Equals, "2010-11-17T03:20:17.832Z") + c.Assert(resp.ConfigurationSettings[0].DateUpdated, Equals, "2010-11-17T03:20:17.832Z") + c.Assert(resp.RequestId, Equals, "4bde8884-f273-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDescribeEnvironmentResources(c *C) { + testServer.Response(200, nil, DescribeEnvironmentResourcesExample) + + options := eb.DescribeEnvironmentResources{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + } + + resp, err := s.eb.DescribeEnvironmentResources(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeEnvironmentResources"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(err, IsNil) + c.Assert(resp.EnvironmentResources[0].EnvironmentName, Equals, "SampleAppVersion") + c.Assert(resp.EnvironmentResources[0].AutoScalingGroups[0].Name, Equals, "elasticbeanstalk-SampleAppVersion-us-east-1c") + c.Assert(resp.EnvironmentResources[0].LoadBalancers[0].Name, Equals, "elasticbeanstalk-SampleAppVersion") + c.Assert(resp.EnvironmentResources[0].LaunchConfigurations[0].Name, Equals, "elasticbeanstalk-SampleAppVersion-hbAc8cSZH7") + c.Assert(resp.EnvironmentResources[0].Triggers[0].Name, Equals, "elasticbeanstalk-SampleAppVersion-us-east-1c") + c.Assert(resp.RequestId, Equals, "e1cb7b96-f287-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDescribeEnvironments(c *C) { + testServer.Response(200, nil, DescribeEnvironmentsExample) + + options := eb.DescribeEnvironments{ + ApplicationName: "SampleApp", + IncludeDeleted: true, + IncludedDeletedBackTo: "2008-11-05T06:00:00Z", + } + + resp, err := s.eb.DescribeEnvironments(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeEnvironments"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["IncludeDeleted"], DeepEquals, []string{"true"}) + c.Assert(req.Form["IncludedDeletedBackTo"], DeepEquals, []string{"2008-11-05T06:00:00Z"}) + c.Assert(err, IsNil) + c.Assert(resp.Environments[0].ApplicationName, Equals, "SampleApp") + c.Assert(resp.Environments[0].CNAME, Equals, "SampleApp-jxb293wg7n.elasticbeanstalk.amazonaws.com") + c.Assert(resp.Environments[0].DateCreated, Equals, "2010-11-17T03:59:33.520Z") + c.Assert(resp.Environments[0].DateUpdated, Equals, "2010-11-17T04:01:40.668Z") + c.Assert(resp.Environments[0].Description, Equals, "EnvDescrip") + c.Assert(resp.Environments[0].EndpointURL, Equals, "elasticbeanstalk-SampleApp-1394386994.us-east-1.elb.amazonaws.com") + c.Assert(resp.Environments[0].EnvironmentId, Equals, "e-icsgecu3wf") + c.Assert(resp.Environments[0].EnvironmentName, Equals, "SampleApp") + c.Assert(resp.Environments[0].Health, Equals, "Green") + c.Assert(resp.Environments[0].SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.Environments[0].Status, Equals, "Available") + c.Assert(resp.Environments[0].VersionLabel, Equals, "Version1") + c.Assert(resp.RequestId, Equals, "44790c68-f260-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestDescribeEvents(c *C) { + testServer.Response(200, nil, DescribeEventsExample) + + options := eb.DescribeEvents{ + ApplicationName: "SampleApp", + Severity: "TRACE", + StartTime: "2010-11-17T10:26:40Z", + } + + resp, err := s.eb.DescribeEvents(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"DescribeEvents"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Severity"], DeepEquals, []string{"TRACE"}) + c.Assert(req.Form["StartTime"], DeepEquals, []string{"2010-11-17T10:26:40Z"}) + c.Assert(err, IsNil) + c.Assert(resp.Events[0].ApplicationName, Equals, "SampleApp") + c.Assert(resp.Events[0].EnvironmentName, Equals, "SampleAppVersion") + c.Assert(resp.Events[0].EventDate, Equals, "2010-11-17T20:25:35.191Z") + c.Assert(resp.Events[0].Message, Equals, "Successfully completed createEnvironment activity.") + c.Assert(resp.Events[0].RequestId, Equals, "bb01fa74-f287-11df-8a78-9f77047e0d0c") + c.Assert(resp.Events[0].Severity, Equals, "INFO") + c.Assert(resp.Events[0].VersionLabel, Equals, "New Version") + c.Assert(resp.RequestId, Equals, "f10d02dd-f288-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestListAvailableSolutionStacks(c *C) { + testServer.Response(200, nil, ListAvailableSolutionStacksExample) + + resp, err := s.eb.ListAvailableSolutionStacks() + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"ListAvailableSolutionStacks"}) + c.Assert(err, IsNil) + c.Assert(resp.SolutionStacks[0], Equals, "64bit Amazon Linux running Tomcat 6") + c.Assert(resp.SolutionStacks[1], Equals, "32bit Amazon Linux running Tomcat 6") + c.Assert(resp.RequestId, Equals, "f21e2a92-f1fc-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestRebuildEnvironment(c *C) { + testServer.Response(200, nil, RebuildEnvironmentExample) + + options := eb.RebuildEnvironment{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + } + + resp, err := s.eb.RebuildEnvironment(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"RebuildEnvironment"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "a7d6606e-f289-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestRequestEnvironmentInfo(c *C) { + testServer.Response(200, nil, RequestEnvironmentInfoExample) + + options := eb.RequestEnvironmentInfo{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + } + + resp, err := s.eb.RequestEnvironmentInfo(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"RequestEnvironmentInfo"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "126a4ff3-f28a-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestRestartAppServer(c *C) { + testServer.Response(200, nil, RestartAppServerExample) + + options := eb.RestartAppServer{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + } + + resp, err := s.eb.RestartAppServer(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"RestartAppServer"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "90e8d1d5-f28a-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestRetrieveEnvironmentInfo(c *C) { + testServer.Response(200, nil, RetrieveEnvironmentInfoExample) + + options := eb.RetrieveEnvironmentInfo{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + InfoType: "tail", + } + + resp, err := s.eb.RetrieveEnvironmentInfo(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"RetrieveEnvironmentInfo"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(req.Form["InfoType"], DeepEquals, []string{"tail"}) + c.Assert(err, IsNil) + c.Assert(resp.EnvironmentInfo[0].Ec2InstanceId, Equals, "i-92a3ceff") + c.Assert(resp.EnvironmentInfo[0].InfoType, Equals, "tail") + c.Assert(resp.EnvironmentInfo[0].Message, Equals, "https://elasticbeanstalk.us-east-1.s3.amazonaws.com/environments%2Fa514386a-709f-4888-9683-068c38d744b4%2Flogs%2Fi-92a3ceff%2F278756a8-7d83-4bc1-93db-b1763163705a.log?Expires=1291236023") + c.Assert(resp.EnvironmentInfo[0].SampleTimestamp, Equals, "2010-11-17T20:40:23.210Z") + c.Assert(resp.RequestId, Equals, "e8e785c9-f28a-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestSwapEnvironmentCNAMEs(c *C) { + testServer.Response(200, nil, SwapEnvironmentCNAMEsExample) + + options := eb.SwapEnvironmentCNAMEs{ + SourceEnvironmentName: "SampleApp", + DestinationEnvironmentName: "SampleApp2", + } + + resp, err := s.eb.SwapEnvironmentCNAMEs(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"SwapEnvironmentCNAMEs"}) + c.Assert(req.Form["SourceEnvironmentName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["DestinationEnvironmentName"], DeepEquals, []string{"SampleApp2"}) + c.Assert(err, IsNil) + c.Assert(resp.RequestId, Equals, "f4e1b145-9080-11e0-8e5a-a558e0ce1fc4") +} + +func (s *S) TestTerminateEnvironment(c *C) { + testServer.Response(200, nil, TerminateEnvironmentExample) + + options := eb.TerminateEnvironment{ + EnvironmentId: "e-icsgecu3wf", + EnvironmentName: "SampleApp", + } + + resp, err := s.eb.TerminateEnvironment(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"TerminateEnvironment"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-icsgecu3wf"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.CNAME, Equals, "SampleApp-jxb293wg7n.elasticbeanstalk.amazonaws.com") + c.Assert(resp.DateCreated, Equals, "2010-11-17T03:59:33.520Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T17:10:41.976Z") + c.Assert(resp.Description, Equals, "EnvDescrip") + c.Assert(resp.EndpointURL, Equals, "elasticbeanstalk-SampleApp-1394386994.us-east-1.elb.amazonaws.com") + c.Assert(resp.EnvironmentId, Equals, "e-icsgecu3wf") + c.Assert(resp.EnvironmentName, Equals, "SampleApp") + c.Assert(resp.Health, Equals, "Grey") + c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.Status, Equals, "Terminating") + c.Assert(resp.VersionLabel, Equals, "Version1") + c.Assert(resp.RequestId, Equals, "9b71af21-f26d-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestUpdateApplication(c *C) { + testServer.Response(200, nil, UpdateApplicationExample) + + options := eb.UpdateApplication{ + ApplicationName: "SampleApp", + Description: "Another Description", + } + + resp, err := s.eb.UpdateApplication(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"UpdateApplication"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"Another Description"}) + c.Assert(err, IsNil) + c.Assert(resp.Application.ApplicationName, Equals, "SampleApp") + c.Assert(resp.Application.ConfigurationTemplates[0], Equals, "Default") + c.Assert(resp.Application.DateCreated, Equals, "2010-11-17T19:26:20.410Z") + c.Assert(resp.Application.DateUpdated, Equals, "2010-11-17T20:42:54.611Z") + c.Assert(resp.Application.Description, Equals, "Another Description") + c.Assert(resp.Application.Versions[0], Equals, "New Version") + c.Assert(resp.RequestId, Equals, "40be666b-f28b-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestUpdateApplicationVersion(c *C) { + testServer.Response(200, nil, UpdateApplicationVersionExample) + + options := eb.UpdateApplicationVersion{ + ApplicationName: "SampleApp", + Description: "New Release Description", + VersionLabel: "New Version", + } + + resp, err := s.eb.UpdateApplicationVersion(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"UpdateApplicationVersion"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"New Release Description"}) + c.Assert(req.Form["VersionLabel"], DeepEquals, []string{"New Version"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationVersion.ApplicationName, Equals, "SampleApp") + c.Assert(resp.ApplicationVersion.DateCreated, Equals, "2010-11-17T19:26:20.699Z") + c.Assert(resp.ApplicationVersion.DateUpdated, Equals, "2010-11-17T20:48:16.632Z") + c.Assert(resp.ApplicationVersion.Description, Equals, "New Release Description") + c.Assert(resp.ApplicationVersion.VersionLabel, Equals, "New Version") + c.Assert(resp.ApplicationVersion.SourceBundle.S3Key, Equals, "sample.war") + c.Assert(resp.ApplicationVersion.SourceBundle.S3Bucket, Equals, "awsemr") + c.Assert(resp.RequestId, Equals, "00b10aa1-f28c-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestUpdateConfigurationTemplate(c *C) { + testServer.Response(200, nil, UpdateConfigurationTemplateExample) + + options := eb.UpdateConfigurationTemplate{ + ApplicationName: "SampleApp", + Description: "changed description", + OptionSettings: []eb.ConfigurationOptionSetting{{ + Namespace: "aws.autoscaling.trigger", + OptionName: "LowerThreshold", + Value: "1000000", + }}, + OptionsToRemove: []eb.OptionSpecification{}, + TemplateName: "default", + } + + resp, err := s.eb.UpdateConfigurationTemplate(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"UpdateConfigurationTemplate"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["Description"], DeepEquals, []string{"changed description"}) + c.Assert(req.Form["OptionSettings.member.1.Namespace"], DeepEquals, []string{"aws.autoscaling.trigger"}) + c.Assert(req.Form["OptionSettings.member.1.OptionName"], DeepEquals, []string{"LowerThreshold"}) + c.Assert(req.Form["OptionSettings.member.1.Value"], DeepEquals, []string{"1000000"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"default"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.TemplateName, Equals, "Default") + c.Assert(resp.OptionSettings[0].OptionName, Equals, "Availability Zones") + c.Assert(resp.OptionSettings[0].Value, Equals, "Any 1") + c.Assert(resp.OptionSettings[0].Namespace, Equals, "aws:autoscaling:asg") + c.Assert(resp.DateCreated, Equals, "2010-11-17T19:26:20.420Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T20:58:27.508Z") + c.Assert(resp.RequestId, Equals, "6cbcb09a-f28d-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestUpdateEnvironment(c *C) { + testServer.Response(200, nil, UpdateEnvironmentExample) + + options := eb.UpdateEnvironment{ + EnvironmentId: "e-hc8mvnayrx", + EnvironmentName: "SampleAppVersion", + OptionsToRemove: []eb.OptionSpecification{{ + Namespace: "aws.autoscaling.trigger", + OptionName: "MeasureName", + }}, + TemplateName: "default", + } + + resp, err := s.eb.UpdateEnvironment(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"UpdateEnvironment"}) + c.Assert(req.Form["EnvironmentId"], DeepEquals, []string{"e-hc8mvnayrx"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(req.Form["OptionsToRemove.member.1.Namespace"], DeepEquals, []string{"aws.autoscaling.trigger"}) + c.Assert(req.Form["OptionsToRemove.member.1.OptionName"], DeepEquals, []string{"MeasureName"}) + c.Assert(req.Form["TemplateName"], DeepEquals, []string{"default"}) + c.Assert(err, IsNil) + c.Assert(resp.ApplicationName, Equals, "SampleApp") + c.Assert(resp.CNAME, Equals, "SampleApp.elasticbeanstalk.amazonaws.com") + c.Assert(resp.DateCreated, Equals, "2010-11-17T20:17:42.339Z") + c.Assert(resp.DateUpdated, Equals, "2010-11-17T21:05:55.251Z") + c.Assert(resp.Description, Equals, "SampleAppDescription") + c.Assert(resp.EndpointURL, Equals, "elasticbeanstalk-SampleAppVersion-246126201.us-east-1.elb.amazonaws.com") + c.Assert(resp.EnvironmentId, Equals, "e-hc8mvnayrx") + c.Assert(resp.EnvironmentName, Equals, "SampleAppVersion") + c.Assert(resp.Health, Equals, "Grey") + c.Assert(resp.SolutionStackName, Equals, "32bit Amazon Linux running Tomcat 7") + c.Assert(resp.Status, Equals, "Deploying") + c.Assert(resp.TemplateName, Equals, "") + c.Assert(resp.VersionLabel, Equals, "New Version") + c.Assert(resp.RequestId, Equals, "7705f0bc-f28e-11df-8a78-9f77047e0d0c") +} + +func (s *S) TestValidateConfigurationSettings(c *C) { + testServer.Response(200, nil, ValidateConfigurationSettingsExample) + + options := eb.ValidateConfigurationSettings{ + ApplicationName: "SampleApp", + EnvironmentName: "SampleAppVersion", + OptionSettings: []eb.ConfigurationOptionSetting{{ + Namespace: "aws.autoscaling.trigger", + OptionName: "LowerThreshold", + Value: "1000000", + }}, + } + + resp, err := s.eb.ValidateConfigurationSettings(&options) + req := testServer.WaitRequest() + + c.Assert(req.Form["Action"], DeepEquals, []string{"ValidateConfigurationSettings"}) + c.Assert(req.Form["ApplicationName"], DeepEquals, []string{"SampleApp"}) + c.Assert(req.Form["EnvironmentName"], DeepEquals, []string{"SampleAppVersion"}) + c.Assert(req.Form["OptionSettings.member.1.Namespace"], DeepEquals, []string{"aws.autoscaling.trigger"}) + c.Assert(req.Form["OptionSettings.member.1.OptionName"], DeepEquals, []string{"LowerThreshold"}) + c.Assert(req.Form["OptionSettings.member.1.Value"], DeepEquals, []string{"1000000"}) + c.Assert(err, IsNil) + c.Assert(resp.Messages[0].Message, Equals, "abc") + c.Assert(resp.Messages[0].Namespace, Equals, "def") + c.Assert(resp.Messages[0].OptionName, Equals, "ghi") + c.Assert(resp.Messages[0].Severity, Equals, "warning") + c.Assert(resp.RequestId, Equals, "06f1cfff-f28f-11df-8a78-9f77047e0d0c") +} diff --git a/eb/responses_test.go b/eb/responses_test.go new file mode 100644 index 00000000..7616a46f --- /dev/null +++ b/eb/responses_test.go @@ -0,0 +1,1691 @@ +package eb_test + +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CheckDNSAvailability.html +var CheckDNSAvailabilityExample = ` + + + sampleapplication.elasticbeanstalk.amazonaws.com + true + + + 12f6701f-f1d6-11df-8a78-9f77047e0d0c + + +` + +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateApplication.html +var CreateApplicationExample = ` + + + + + Sample Description + SampleApp + 2010-11-16T23:09:20.256Z + 2010-11-16T23:09:20.256Z + + Default + + + + + 8b00e053-f1d6-11df-8a78-9f77047e0d0c + + +` + +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateApplicationVersion.html +var CreateApplicationVersionExample = ` + + + + + amazonaws.com + sample.war + + Version1 + description + SampleApp + 2010-11-17T03:21:59.161Z + 2010-11-17T03:21:59.161Z + + + + d653efef-f1f9-11df-8a78-9f77047e0d0c + + +` + +var CreateConfigurationTemplateExample = ` + + + 32bit Amazon Linux running Tomcat 7 + + + ImageId + ami-f2f0069b + aws:autoscaling:launchconfiguration + + + Notification Endpoint + + aws:elasticbeanstalk:sns:topics + + + PARAM4 + + aws:elasticbeanstalk:application:environment + + + JDBC_CONNECTION_STRING + + aws:elasticbeanstalk:application:environment + + + SecurityGroups + elasticbeanstalk-default + aws:autoscaling:launchconfiguration + + + UnhealthyThreshold + 5 + aws:elb:healthcheck + + + InstanceType + t1.micro + aws:autoscaling:launchconfiguration + + + Statistic + Average + aws:autoscaling:trigger + + + LoadBalancerHTTPSPort + OFF + aws:elb:loadbalancer + + + Stickiness Cookie Expiration + 0 + aws:elb:policies + + + PARAM5 + + aws:elasticbeanstalk:application:environment + + + MeasureName + NetworkOut + aws:autoscaling:trigger + + + Interval + 30 + aws:elb:healthcheck + + + Application Healthcheck URL + / + aws:elasticbeanstalk:application + + + Notification Topic ARN + + aws:elasticbeanstalk:sns:topics + + + LowerBreachScaleIncrement + -1 + aws:autoscaling:trigger + + + XX:MaxPermSize + 64m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + UpperBreachScaleIncrement + 1 + aws:autoscaling:trigger + + + MinSize + 1 + aws:autoscaling:asg + + + Custom Availability Zones + us-east-1a + aws:autoscaling:asg + + + Availability Zones + Any 1 + aws:autoscaling:asg + + + LogPublicationControl + false + aws:elasticbeanstalk:hostmanager + + + JVM Options + + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + Notification Topic Name + + aws:elasticbeanstalk:sns:topics + + + PARAM2 + + aws:elasticbeanstalk:application:environment + + + LoadBalancerHTTPPort + 80 + aws:elb:loadbalancer + + + Timeout + 5 + aws:elb:healthcheck + + + BreachDuration + 2 + aws:autoscaling:trigger + + + MonitoringInterval + 5 minute + aws:autoscaling:launchconfiguration + + + PARAM1 + + aws:elasticbeanstalk:application:environment + + + MaxSize + 4 + aws:autoscaling:asg + + + LowerThreshold + 2000000 + aws:autoscaling:trigger + + + AWS_SECRET_KEY + + aws:elasticbeanstalk:application:environment + + + AWS_ACCESS_KEY_ID + + aws:elasticbeanstalk:application:environment + + + UpperThreshold + 6000000 + aws:autoscaling:trigger + + + Notification Protocol + email + aws:elasticbeanstalk:sns:topics + + + Unit + Bytes + aws:autoscaling:trigger + + + Xmx + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + Cooldown + 360 + aws:autoscaling:asg + + + Period + 1 + aws:autoscaling:trigger + + + Xms + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + EC2KeyName + + aws:autoscaling:launchconfiguration + + + Stickiness Policy + false + aws:elb:policies + + + PARAM3 + + aws:elasticbeanstalk:application:environment + + + HealthyThreshold + 3 + aws:elb:healthcheck + + + SSLCertificateId + + aws:elb:loadbalancer + + + ConfigTemplateDescription + SampleApp + 2010-11-17T03:48:19.640Z + AppTemplate + 2010-11-17T03:48:19.640Z + + + 846cd905-f1fd-11df-8a78-9f77047e0d0c + + +` + +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateEnvironment.html +var CreateEnvironmentExample = ` + + + Version1 + Deploying + SampleApp + Grey + e-icsgecu3wf + 2010-11-17T03:59:33.520Z + 32bit Amazon Linux running Tomcat 7 + EnvDescrip + SampleApp + 2010-11-17T03:59:33.520Z + + + 15db925e-f1ff-11df-8a78-9f77047e0d0c + + +` + +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_CreateStorageLocation.html +var CreateStorageLocationExample = ` + + + elasticbeanstalk-us-east-1-780612358023 + + + ef51b94a-f1d6-11df-8a78-9f77047e0d0c + + +` + +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_DeleteApplication.html +var DeleteApplicationExample = ` + + + 1f155abd-f1d7-11df-8a78-9f77047e0d0c + + +` + +// http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_DeleteApplicationVersion.html +var DeleteApplicationVersionExample = ` + + + 58dc7339-f272-11df-8a78-9f77047e0d0c + + +` + +var DeleteConfigurationTemplateExample = ` + + + af9cf1b6-f25e-11df-8a78-9f77047e0d0c + + +` + +var DeleteEnvironmentConfigurationExample = ` + + + fdf76507-f26d-11df-8a78-9f77047e0d0c + + +` + +var DescribeApplicationVersionsExample = ` + + + + + + amazonaws.com + sample.war + + Version1 + description + SampleApp + 2010-11-17T03:21:59.161Z + 2010-11-17T03:21:59.161Z + + + + + 773cd80a-f26c-11df-8a78-9f77047e0d0c + + +` + +var DescribeApplicationsExample = ` + + + + + + Sample Description + SampleApplication + 2010-11-16T20:20:51.974Z + 2010-11-16T20:20:51.974Z + + Default + + + + + + 577c70ff-f1d7-11df-8a78-9f77047e0d0c + + +` + +var DescribeConfigurationOptionsExample = ` + + + 32bit Amazon Linux running Tomcat 7 + + + false + RestartEnvironment + 2000 + ImageId + Scalar + ami-6036c009 + aws:autoscaling:launchconfiguration + + + false + NoInterruption + 2000 + Notification Endpoint + Scalar + + aws:elasticbeanstalk:sns:topics + + + false + RestartApplicationServer + 2000 + PARAM4 + Scalar + + aws:elasticbeanstalk:application:environment + + + false + RestartApplicationServer + 2000 + JDBC_CONNECTION_STRING + Scalar + + aws:elasticbeanstalk:application:environment + + + false + RestartEnvironment + 2000 + SecurityGroups + Scalar + elasticbeanstalk-default + aws:autoscaling:launchconfiguration + + + false + NoInterruption + 2 + UnhealthyThreshold + Scalar + 5 + 10 + aws:elb:healthcheck + + + false + RestartEnvironment + InstanceType + + t1.micro + m1.small + + Scalar + t1.micro + aws:autoscaling:launchconfiguration + + + false + NoInterruption + Statistic + + Minimum + Maximum + Sum + Average + + Scalar + Average + aws:autoscaling:trigger + + + false + RestartEnvironment + LoadBalancerHTTPSPort + + OFF + 443 + 8443 + 5443 + + Scalar + OFF + aws:elb:loadbalancer + + + false + NoInterruption + 0 + Stickiness Cookie Expiration + Scalar + 0 + 1000000 + aws:elb:policies + + + false + RestartApplicationServer + 2000 + PARAM5 + Scalar + + aws:elasticbeanstalk:application:environment + + + false + NoInterruption + MeasureName + + CPUUtilization + NetworkIn + NetworkOut + DiskWriteOps + DiskReadBytes + DiskReadOps + DiskWriteBytes + Latency + RequestCount + HealthyHostCount + UnhealthyHostCount + + Scalar + NetworkOut + aws:autoscaling:trigger + + + false + NoInterruption + 5 + Interval + Scalar + 30 + 300 + aws:elb:healthcheck + + + false + NoInterruption + 2000 + Application Healthcheck URL + Scalar + / + aws:elasticbeanstalk:application + + + false + NoInterruption + 2000 + Notification Topic ARN + Scalar + + aws:elasticbeanstalk:sns:topics + + + false + NoInterruption + 2000 + LowerBreachScaleIncrement + Scalar + -1 + aws:autoscaling:trigger + + + false + RestartApplicationServer + 2000 + + ^\S*$ + + + XX:MaxPermSize + Scalar + 64m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + false + NoInterruption + 2000 + UpperBreachScaleIncrement + Scalar + 1 + aws:autoscaling:trigger + + + false + NoInterruption + 1 + MinSize + Scalar + 1 + 10000 + aws:autoscaling:asg + + + false + RestartEnvironment + Custom Availability Zones + + us-east-1a + us-east-1b + us-east-1c + us-east-1d + + List + us-east-1a + aws:autoscaling:asg + + + false + RestartEnvironment + Availability Zones + + Any 1 + Any 2 + + Scalar + Any 1 + aws:autoscaling:asg + + + false + NoInterruption + LogPublicationControl + Boolean + false + aws:elasticbeanstalk:hostmanager + + + false + RestartApplicationServer + 2000 + JVM Options + Scalar + + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + false + NoInterruption + 2000 + Notification Topic Name + Scalar + + aws:elasticbeanstalk:sns:topics + + + false + RestartApplicationServer + 2000 + PARAM2 + Scalar + + aws:elasticbeanstalk:application:environment + + + false + RestartEnvironment + LoadBalancerHTTPPort + + OFF + 80 + 8080 + + Scalar + 80 + aws:elb:loadbalancer + + + false + NoInterruption + 2 + Timeout + Scalar + 5 + 60 + aws:elb:healthcheck + + + false + NoInterruption + 1 + BreachDuration + Scalar + 2 + 600 + aws:autoscaling:trigger + + + false + RestartEnvironment + MonitoringInterval + + 1 minute + 5 minute + + Scalar + 5 minute + aws:autoscaling:launchconfiguration + + + false + RestartApplicationServer + 2000 + PARAM1 + Scalar + + aws:elasticbeanstalk:application:environment + + + false + NoInterruption + 1 + MaxSize + Scalar + 4 + 10000 + aws:autoscaling:asg + + + false + NoInterruption + 0 + LowerThreshold + Scalar + 2000000 + 20000000 + aws:autoscaling:trigger + + + false + RestartApplicationServer + 2000 + AWS_SECRET_KEY + Scalar + + aws:elasticbeanstalk:application:environment + + + false + RestartApplicationServer + 2000 + AWS_ACCESS_KEY_ID + Scalar + + aws:elasticbeanstalk:application:environment + + + false + NoInterruption + 0 + UpperThreshold + Scalar + 6000000 + 20000000 + aws:autoscaling:trigger + + + false + NoInterruption + Notification Protocol + + http + https + email + email-json + sqs + + Scalar + email + aws:elasticbeanstalk:sns:topics + + + false + NoInterruption + Unit + + Seconds + Percent + Bytes + Bits + Count + Bytes/Second + Bits/Second + Count/Second + None + + Scalar + Bytes + aws:autoscaling:trigger + + + false + RestartApplicationServer + 2000 + + ^\S*$ + + + Xmx + Scalar + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + false + NoInterruption + 0 + Cooldown + Scalar + 360 + 10000 + aws:autoscaling:asg + + + false + NoInterruption + 1 + Period + Scalar + 1 + 600 + aws:autoscaling:trigger + + + false + RestartApplicationServer + 2000 + + ^\S*$ + + + Xms + Scalar + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + false + RestartEnvironment + 2000 + EC2KeyName + Scalar + + aws:autoscaling:launchconfiguration + + + false + NoInterruption + Stickiness Policy + Boolean + false + aws:elb:policies + + + false + RestartApplicationServer + 2000 + PARAM3 + Scalar + + aws:elasticbeanstalk:application:environment + + + false + NoInterruption + 2 + HealthyThreshold + Scalar + 3 + 10 + aws:elb:healthcheck + + + false + RestartEnvironment + 2000 + SSLCertificateId + Scalar + + aws:elb:loadbalancer + + + + + e8768900-f272-11df-8a78-9f77047e0d0c + + +` + +var DescribeConfigurationSettingsExample = ` + + + + + 32bit Amazon Linux running Tomcat 7 + + + ImageId + ami-f2f0069b + aws:autoscaling:launchconfiguration + + + Notification Endpoint + + aws:elasticbeanstalk:sns:topics + + + PARAM4 + + aws:elasticbeanstalk:application:environment + + + JDBC_CONNECTION_STRING + + aws:elasticbeanstalk:application:environment + + + SecurityGroups + elasticbeanstalk-default + aws:autoscaling:launchconfiguration + + + UnhealthyThreshold + 5 + aws:elb:healthcheck + + + InstanceType + t1.micro + aws:autoscaling:launchconfiguration + + + Statistic + Average + aws:autoscaling:trigger + + + LoadBalancerHTTPSPort + OFF + aws:elb:loadbalancer + + + Stickiness Cookie Expiration + 0 + aws:elb:policies + + + PARAM5 + + aws:elasticbeanstalk:application:environment + + + MeasureName + NetworkOut + aws:autoscaling:trigger + + + Interval + 30 + aws:elb:healthcheck + + + Application Healthcheck URL + / + aws:elasticbeanstalk:application + + + Notification Topic ARN + + aws:elasticbeanstalk:sns:topics + + + LowerBreachScaleIncrement + -1 + aws:autoscaling:trigger + + + XX:MaxPermSize + 64m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + UpperBreachScaleIncrement + 1 + aws:autoscaling:trigger + + + MinSize + 1 + aws:autoscaling:asg + + + Custom Availability Zones + us-east-1a + aws:autoscaling:asg + + + Availability Zones + Any 1 + aws:autoscaling:asg + + + LogPublicationControl + false + aws:elasticbeanstalk:hostmanager + + + JVM Options + + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + Notification Topic Name + + aws:elasticbeanstalk:sns:topics + + + PARAM2 + + aws:elasticbeanstalk:application:environment + + + LoadBalancerHTTPPort + 80 + aws:elb:loadbalancer + + + Timeout + 5 + aws:elb:healthcheck + + + BreachDuration + 2 + aws:autoscaling:trigger + + + MonitoringInterval + 5 minute + aws:autoscaling:launchconfiguration + + + PARAM1 + + aws:elasticbeanstalk:application:environment + + + MaxSize + 4 + aws:autoscaling:asg + + + LowerThreshold + 2000000 + aws:autoscaling:trigger + + + AWS_SECRET_KEY + + aws:elasticbeanstalk:application:environment + + + AWS_ACCESS_KEY_ID + + aws:elasticbeanstalk:application:environment + + + UpperThreshold + 6000000 + aws:autoscaling:trigger + + + Notification Protocol + email + aws:elasticbeanstalk:sns:topics + + + Unit + Bytes + aws:autoscaling:trigger + + + Xmx + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + Cooldown + 360 + aws:autoscaling:asg + + + Period + 1 + aws:autoscaling:trigger + + + Xms + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + EC2KeyName + + aws:autoscaling:launchconfiguration + + + Stickiness Policy + false + aws:elb:policies + + + PARAM3 + + aws:elasticbeanstalk:application:environment + + + HealthyThreshold + 3 + aws:elb:healthcheck + + + SSLCertificateId + + aws:elb:loadbalancer + + + Default Configuration Template + SampleApp + 2010-11-17T03:20:17.832Z + Default + 2010-11-17T03:20:17.832Z + + + + + 4bde8884-f273-11df-8a78-9f77047e0d0c + + +` + +var DescribeEnvironmentResourcesExample = ` + + + + + + elasticbeanstalk-SampleAppVersion + + + + + elasticbeanstalk-SampleAppVersion-hbAc8cSZH7 + + + + + elasticbeanstalk-SampleAppVersion-us-east-1c + + + SampleAppVersion + + + elasticbeanstalk-SampleAppVersion-us-east-1c + + + + + + + e1cb7b96-f287-11df-8a78-9f77047e0d0c + + +` +var DescribeEnvironmentsExample = ` + + + + + Version1 + Available + SampleApp + elasticbeanstalk-SampleApp-1394386994.us-east-1.elb.amazonaws.com + SampleApp-jxb293wg7n.elasticbeanstalk.amazonaws.com + Green + e-icsgecu3wf + 2010-11-17T04:01:40.668Z + 32bit Amazon Linux running Tomcat 7 + EnvDescrip + SampleApp + 2010-11-17T03:59:33.520Z + + + + + 44790c68-f260-11df-8a78-9f77047e0d0c + + +` + +var DescribeEventsExample = ` + + + + + Successfully completed createEnvironment activity. + 2010-11-17T20:25:35.191Z + New Version + bb01fa74-f287-11df-8a78-9f77047e0d0c + SampleApp + SampleAppVersion + INFO + + + Launching a new EC2 instance: i-04a8c569 + 2010-11-17T20:21:30Z + New Version + SampleApp + SampleAppVersion + DEBUG + + + At least one EC2 instance has entered the InService lifecycle state. + 2010-11-17T20:20:32.008Z + New Version + bb01fa74-f287-11df-8a78-9f77047e0d0c + SampleApp + SampleAppVersion + INFO + + + Elastic Load Balancer elasticbeanstalk-SampleAppVersion has failed 0 healthy instances - Environment may not be available. + 2010-11-17T20:19:28Z + New Version + SampleApp + SampleAppVersion + WARN + + + + + f10d02dd-f288-11df-8a78-9f77047e0d0c + + +` +var ListAvailableSolutionStacksExample = ` + + + + 64bit Amazon Linux running Tomcat 6 + 32bit Amazon Linux running Tomcat 6 + 64bit Amazon Linux running Tomcat 7 + 32bit Amazon Linux running Tomcat 7 + + + + f21e2a92-f1fc-11df-8a78-9f77047e0d0c + + +` + +var RebuildEnvironmentExample = ` + + + a7d6606e-f289-11df-8a78-9f77047e0d0c + + +` + +var RequestEnvironmentInfoExample = ` + + + 126a4ff3-f28a-11df-8a78-9f77047e0d0c + + +` + +var RestartAppServerExample = ` + + + 90e8d1d5-f28a-11df-8a78-9f77047e0d0c + + +` + +var RetrieveEnvironmentInfoExample = ` + + + + + https://elasticbeanstalk.us-east-1.s3.amazonaws.com/environments%2Fa514386a-709f-4888-9683-068c38d744b4%2Flogs%2Fi-92a3ceff%2F278756a8-7d83-4bc1-93db-b1763163705a.log?Expires=1291236023 + 2010-11-17T20:40:23.210Z + tail + i-92a3ceff + + + + + e8e785c9-f28a-11df-8a78-9f77047e0d0c + + +` + +var SwapEnvironmentCNAMEsExample = ` + + + f4e1b145-9080-11e0-8e5a-a558e0ce1fc4 + + +` + +var UpdateApplicationExample = ` + + + + + New Version + + Another Description + SampleApp + 2010-11-17T19:26:20.410Z + 2010-11-17T20:42:54.611Z + + Default + + + + + 40be666b-f28b-11df-8a78-9f77047e0d0c + + +` +var TerminateEnvironmentExample = ` + + + Version1 + Terminating + SampleApp + elasticbeanstalk-SampleApp-1394386994.us-east-1.elb.amazonaws.com + SampleApp-jxb293wg7n.elasticbeanstalk.amazonaws.com + Grey + e-icsgecu3wf + 2010-11-17T17:10:41.976Z + 32bit Amazon Linux running Tomcat 7 + EnvDescrip + SampleApp + 2010-11-17T03:59:33.520Z + + + 9b71af21-f26d-11df-8a78-9f77047e0d0c + + +` + +var UpdateApplicationVersionExample = ` + + + + + awsemr + sample.war + + New Version + New Release Description + SampleApp + 2010-11-17T19:26:20.699Z + 2010-11-17T20:48:16.632Z + + + + 00b10aa1-f28c-11df-8a78-9f77047e0d0c + + +` + +var UpdateConfigurationTemplateExample = ` + + + 32bit Amazon Linux running Tomcat 7 + + + Availability Zones + Any 1 + aws:autoscaling:asg + + + PARAM5 + + aws:elasticbeanstalk:application:environment + + + LowerThreshold + 1000000 + aws:autoscaling:trigger + + + UpperThreshold + 9000000 + aws:autoscaling:trigger + + + LowerBreachScaleIncrement + -1 + aws:autoscaling:trigger + + + MeasureName + NetworkOut + aws:autoscaling:trigger + + + Period + 60 + aws:autoscaling:trigger + + + Xmx + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + PARAM3 + + aws:elasticbeanstalk:application:environment + + + EC2KeyName + + aws:autoscaling:launchconfiguration + + + MinSize + 1 + aws:autoscaling:asg + + + JVM Options + + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + XX:MaxPermSize + 64m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + AWS_SECRET_KEY + + aws:elasticbeanstalk:application:environment + + + UpperBreachScaleIncrement + 1 + aws:autoscaling:trigger + + + Notification Topic ARN + + aws:elasticbeanstalk:sns:topics + + + InstanceType + t1.micro + aws:autoscaling:launchconfiguration + + + Custom Availability Zones + us-east-1a + aws:autoscaling:asg + + + Statistic + Average + aws:autoscaling:trigger + + + Notification Protocol + email + aws:elasticbeanstalk:sns:topics + + + JDBC_CONNECTION_STRING + + aws:elasticbeanstalk:application:environment + + + PARAM2 + + aws:elasticbeanstalk:application:environment + + + Stickiness Cookie Expiration + 0 + aws:elb:policies + + + SSLCertificateId + + aws:elb:loadbalancer + + + MaxSize + 4 + aws:autoscaling:asg + + + Stickiness Policy + false + aws:elb:policies + + + Notification Topic Name + + aws:elasticbeanstalk:sns:topics + + + SecurityGroups + elasticbeanstalk-default + aws:autoscaling:launchconfiguration + + + LoadBalancerHTTPPort + 80 + aws:elb:loadbalancer + + + Unit + None + aws:autoscaling:trigger + + + AWS_ACCESS_KEY_ID + + aws:elasticbeanstalk:application:environment + + + PARAM4 + + aws:elasticbeanstalk:application:environment + + + Application Healthcheck URL + / + aws:elasticbeanstalk:application + + + LoadBalancerHTTPSPort + OFF + aws:elb:loadbalancer + + + HealthyThreshold + 3 + aws:elb:healthcheck + + + Timeout + 5 + aws:elb:healthcheck + + + Cooldown + 0 + aws:autoscaling:asg + + + UnhealthyThreshold + 5 + aws:elb:healthcheck + + + Interval + 30 + aws:elb:healthcheck + + + LogPublicationControl + false + aws:elasticbeanstalk:hostmanager + + + BreachDuration + 120 + aws:autoscaling:trigger + + + PARAM1 + + aws:elasticbeanstalk:application:environment + + + Notification Endpoint + + aws:elasticbeanstalk:sns:topics + + + Protocol + HTTP + aws:elb:loadbalancer + + + Xms + 256m + aws:elasticbeanstalk:container:tomcat:jvmoptions + + + changed description + SampleApp + 2010-11-17T19:26:20.420Z + Default + 2010-11-17T20:58:27.508Z + + + 6cbcb09a-f28d-11df-8a78-9f77047e0d0c + + +` + +var UpdateEnvironmentExample = ` + + + New Version + Deploying + SampleApp + elasticbeanstalk-SampleAppVersion-246126201.us-east-1.elb.amazonaws.com + SampleApp.elasticbeanstalk.amazonaws.com + Grey + e-hc8mvnayrx + 2010-11-17T21:05:55.251Z + 32bit Amazon Linux running Tomcat 7 + SampleAppDescription + SampleAppVersion + 2010-11-17T20:17:42.339Z + + + 7705f0bc-f28e-11df-8a78-9f77047e0d0c + + +` + +var ValidateConfigurationSettingsExample = ` + + + + + abc + def + ghi + warning + + + + + 06f1cfff-f28f-11df-8a78-9f77047e0d0c + + +` diff --git a/eb/sign.go b/eb/sign.go new file mode 100644 index 00000000..eea0a78b --- /dev/null +++ b/eb/sign.go @@ -0,0 +1,38 @@ +package eb + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/base64" + "github.com/mitchellh/goamz/aws" + "sort" + "strings" +) + +// ---------------------------------------------------------------------------- +// Version 2 signing (http://goo.gl/RSRp5) + +var b64 = base64.StdEncoding + +func sign(auth aws.Auth, method, path string, params map[string]string, host string) { + params["AWSAccessKeyId"] = auth.AccessKey + params["SignatureVersion"] = "2" + params["SignatureMethod"] = "HmacSHA256" + if auth.Token != "" { + params["SecurityToken"] = auth.Token + } + + var sarray []string + for k, v := range params { + sarray = append(sarray, aws.Encode(k)+"="+aws.Encode(v)) + } + sort.StringSlice(sarray).Sort() + joined := strings.Join(sarray, "&") + payload := method + "\n" + host + "\n" + path + "\n" + joined + hash := hmac.New(sha256.New, []byte(auth.SecretKey)) + hash.Write([]byte(payload)) + signature := make([]byte, b64.EncodedLen(hash.Size())) + b64.Encode(signature, hash.Sum(nil)) + + params["Signature"] = string(signature) +}