-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ComputePlatform to aws_codedeploy_app #4811
Changes from 2 commits
685fdc2
f6cf7ee
93d06c7
547ad10
13e67da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import ( | |
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/awserr" | ||
"github.com/aws/aws-sdk-go/service/codedeploy" | ||
"github.com/hashicorp/terraform/helper/validation" | ||
) | ||
|
||
func resourceAwsCodeDeployApp() *schema.Resource { | ||
|
@@ -26,6 +27,16 @@ func resourceAwsCodeDeployApp() *schema.Resource { | |
ForceNew: true, | ||
}, | ||
|
||
"compute_platform": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
codedeploy.ComputePlatformServer, | ||
codedeploy.ComputePlatformLambda, | ||
}, false), | ||
Default: codedeploy.ComputePlatformServer, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should check the default value in resource.TestCheckResourceAttr("aws_codedeploy_app.foo", "compute_platform", "Server"), |
||
}, | ||
|
||
// The unique ID is set by AWS on create. | ||
"unique_id": &schema.Schema{ | ||
Type: schema.TypeString, | ||
|
@@ -40,10 +51,12 @@ func resourceAwsCodeDeployAppCreate(d *schema.ResourceData, meta interface{}) er | |
conn := meta.(*AWSClient).codedeployconn | ||
|
||
application := d.Get("name").(string) | ||
computePlatform := d.Get("compute_platform").(string) | ||
log.Printf("[DEBUG] Creating CodeDeploy application %s", application) | ||
|
||
resp, err := conn.CreateApplication(&codedeploy.CreateApplicationInput{ | ||
ApplicationName: aws.String(application), | ||
ComputePlatform: aws.String(computePlatform), | ||
}) | ||
if err != nil { | ||
return err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ resource "aws_codedeploy_app" "foo" { | |
The following arguments are supported: | ||
|
||
* `name` - (Required) The name of the application. | ||
* `compute_platform` - (Optional) The compute platform can either be `Server` or `Lambda`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should list the default of |
||
|
||
## Attribute Reference | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two subtle, but important bugs with this attribute currently. 😄
d.Set("compute_platform", ...)
which has two implications: Terraform cannot detect drift of the attribute and in absence of thed.Set()
call with the value, Terraform core is silently passing the configuration value into the Terraform state (which is why the acceptance testing passes)UpdateApplication
and therefore needs to be set asForceNew: true
to force new resource creationOne other minor nitpick: (the rest of the file hasn't been updated yet, but) as of Go 1.7, the
&schema.Schema
is extraneous as its defined bymap[string]*schema.Schema
above so we prefer to remove them now 👍