Get Elastic Beanstalk sample working again
Changes the Source property on AWS S3 Objects to be an `in` property. Adds an AllOptionSettings output property to store the settings returned from AWS. This unblocks keeping Beanstalk workign while we evaluate options for #189. Silently skip unsupported AWS ElasticBeanstalk Environment properties in Get operation. Fixes ARN resource name pair extraction to skip the "/" between parts of the name pair.
This commit is contained in:
parent
ce35fc78cf
commit
6194945c27
9 changed files with 26 additions and 16 deletions
|
@ -51,9 +51,11 @@ type Environment struct {
|
|||
Tier *Tier `lumi:"tier,optional,replaces"`
|
||||
// The version to associate with the environment.
|
||||
Version *ApplicationVersion `lumi:"version,optional"`
|
||||
|
||||
// The URL to the load balancer for this environment.
|
||||
EndpointURL string `lumi:"endpointURL,out"`
|
||||
// Key-value pairs defining all of the configuration options for this environment, including both values provided
|
||||
// in the OptionSettings input, as well as settings with default values.
|
||||
AllOptionSettings *[]OptionSetting `lumi:"allOptionSettings,out"`
|
||||
}
|
||||
|
||||
// OptionSetting specifies options for an Elastic Beanstalk environment.
|
||||
|
|
|
@ -27,5 +27,5 @@ type Object struct {
|
|||
// The Bucket this object belongs to.
|
||||
Bucket *Bucket `lumi:"bucket,replaces"`
|
||||
// The Source of content for this object.
|
||||
Source *idl.Asset `lumi:"source,replaces"`
|
||||
Source *idl.Asset `lumi:"source,replaces,in"`
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ export class Environment extends lumi.Resource implements EnvironmentArgs {
|
|||
public readonly tier?: Tier;
|
||||
public version?: ApplicationVersion;
|
||||
@lumi.out public endpointURL: string;
|
||||
@lumi.out public allOptionSettings: OptionSetting[];
|
||||
|
||||
constructor(name: string, args: EnvironmentArgs) {
|
||||
super();
|
||||
|
|
|
@ -186,7 +186,7 @@ func (a ARNParts) ResourceName() string {
|
|||
func (a ARNParts) ResourceNamePair() (string, string) {
|
||||
name := a.ResourceName()
|
||||
if ix := strings.Index(name, "/"); ix != -1 {
|
||||
return name[:ix], name[ix:]
|
||||
return name[:ix], name[ix+1:]
|
||||
}
|
||||
return name, ""
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ func (p *environmentProvider) Create(ctx context.Context, obj *elasticbeanstalk.
|
|||
}
|
||||
var versionLabel *string
|
||||
if obj.Version != nil {
|
||||
version, err := arn.ParseResourceName(*obj.Version)
|
||||
_, version, err := arn.ParseResourceNamePair(*obj.Version)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -132,7 +132,6 @@ func (p *environmentProvider) Create(ctx context.Context, obj *elasticbeanstalk.
|
|||
return "", fmt.Errorf("Timed out waiting for environment to become ready")
|
||||
}
|
||||
|
||||
fmt.Printf("Created ElasticBeanstalk Environment '%v' with EndpointURL: %v\n", name, *endpointURL)
|
||||
return arn.NewElasticBeanstalkEnvironmentID(p.ctx.Region(), p.ctx.AccountID(), appname, name), nil
|
||||
}
|
||||
|
||||
|
@ -157,9 +156,7 @@ func (p *environmentProvider) Get(ctx context.Context, id resource.ID) (*elastic
|
|||
// Successfully found the environment, now map all of its properties onto the struct.
|
||||
contract.Assert(len(envresp.Environments) == 1)
|
||||
env := envresp.Environments[0]
|
||||
if env.CNAME != nil || env.TemplateName != nil || env.Tier != nil {
|
||||
return nil, fmt.Errorf("Properties not yet supported: CNAMEPrefix, TemplateName, Tier")
|
||||
}
|
||||
|
||||
var versionLabel *resource.ID
|
||||
if env.VersionLabel != nil {
|
||||
version := arn.NewElasticBeanstalkApplicationVersionID(
|
||||
|
@ -175,9 +172,18 @@ func (p *environmentProvider) Get(ctx context.Context, id resource.ID) (*elastic
|
|||
EndpointURL: aws.StringValue(env.EndpointURL),
|
||||
}
|
||||
|
||||
// TODO[pulumi/lumi#189] We may want to call `DecribeConfigurationSettings` to populate all of
|
||||
// the option settings onto the returned object. However, this returns all of the settings with
|
||||
// their default values, not just those provided as input. This leads to signalling deletions
|
||||
// on future updates. For now, we will populate a seperate output property with the full set
|
||||
// of settings, but we should revisist this once we've resolved #189.
|
||||
|
||||
// Next see if there are any configuration option settings and, if so, set them on the return.
|
||||
confresp, err := p.ctx.ElasticBeanstalk().DescribeConfigurationSettings(
|
||||
&awselasticbeanstalk.DescribeConfigurationSettingsInput{EnvironmentName: aws.String(envname)})
|
||||
&awselasticbeanstalk.DescribeConfigurationSettingsInput{
|
||||
ApplicationName: aws.String(appname),
|
||||
EnvironmentName: aws.String(envname),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -192,7 +198,7 @@ func (p *environmentProvider) Get(ctx context.Context, id resource.ID) (*elastic
|
|||
})
|
||||
}
|
||||
}
|
||||
envobj.OptionSettings = &options
|
||||
envobj.AllOptionSettings = &options
|
||||
}
|
||||
|
||||
return envobj, nil
|
||||
|
@ -249,7 +255,7 @@ func (p *environmentProvider) Update(ctx context.Context, id resource.ID,
|
|||
return err
|
||||
}
|
||||
succ, err := awsctx.RetryUntilLong(p.ctx, func() (bool, error) {
|
||||
fmt.Printf("Waiting for environment %v to become Ready\n", id.String())
|
||||
fmt.Printf("Waiting for environment %v to become Ready\n", envname)
|
||||
resp, err := p.getEnvironment(appname, envname)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
@ -284,7 +290,7 @@ func (p *environmentProvider) Delete(ctx context.Context, id resource.ID) error
|
|||
return err
|
||||
}
|
||||
succ, err := awsctx.RetryUntilLong(p.ctx, func() (bool, error) {
|
||||
fmt.Printf("Waiting for environment %v to become Terminated\n", id.String())
|
||||
fmt.Printf("Waiting for environment %v to become Terminated\n", envname)
|
||||
resp, err := p.getEnvironment(appname, envname)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
|
@ -128,7 +128,7 @@ func (p *buckProvider) Get(ctx context.Context, id resource.ID) (*s3.Bucket, err
|
|||
// InspectChange checks what impacts a hypothetical update will have on the resource's properties.
|
||||
func (p *buckProvider) InspectChange(ctx context.Context, id resource.ID,
|
||||
old *s3.Bucket, new *s3.Bucket, diff *resource.ObjectDiff) ([]string, error) {
|
||||
return nil, errors.New("Not yet implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Update updates an existing resource with new values. Only those values in the provided property bag are updated
|
||||
|
|
|
@ -127,14 +127,13 @@ func (p *objProvider) Get(ctx context.Context, id resource.ID) (*s3.Object, erro
|
|||
return &s3.Object{
|
||||
Bucket: resource.ID(arn.NewS3Bucket(buck)),
|
||||
Key: key,
|
||||
Source: resource.NewURIAsset(fmt.Sprintf("s3://%v/%v", buck, key)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// InspectChange checks what impacts a hypothetical update will have on the resource's properties.
|
||||
func (p *objProvider) InspectChange(ctx context.Context, id resource.ID,
|
||||
old *s3.Object, new *s3.Object, diff *resource.ObjectDiff) ([]string, error) {
|
||||
return nil, errors.New("Not yet implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Update updates an existing resource with new values. Only those values in the provided property bag are updated
|
||||
|
|
|
@ -204,6 +204,7 @@ type Environment struct {
|
|||
Tier *Tier `json:"tier,omitempty"`
|
||||
Version *resource.ID `json:"version,omitempty"`
|
||||
EndpointURL string `json:"endpointURL,omitempty"`
|
||||
AllOptionSettings *[]OptionSetting `json:"allOptionSettings,omitempty"`
|
||||
}
|
||||
|
||||
// Environment's properties have constants to make dealing with diffs and property bags easier.
|
||||
|
@ -220,6 +221,7 @@ const (
|
|||
Environment_Tier = "tier"
|
||||
Environment_Version = "version"
|
||||
Environment_EndpointURL = "endpointURL"
|
||||
Environment_AllOptionSettings = "allOptionSettings"
|
||||
)
|
||||
|
||||
/* Marshalable OptionSetting structure(s) */
|
||||
|
|
|
@ -176,7 +176,7 @@ func (p *ObjectProvider) Unmarshal(
|
|||
type Object struct {
|
||||
Key string `json:"key"`
|
||||
Bucket resource.ID `json:"bucket"`
|
||||
Source resource.Asset `json:"source"`
|
||||
Source *resource.Asset `json:"source,omitempty"`
|
||||
}
|
||||
|
||||
// Object's properties have constants to make dealing with diffs and property bags easier.
|
||||
|
|
Loading…
Reference in a new issue