-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
provider/aws: New resource codepipeline #11814
Conversation
Test passing
|
@heimweh is back and helped me finish this. Any input needed to get this finished would be great. |
@stack72 We're actively using this while developing our infrastructure. If you have any feedback on the schema before we spend too much time on it would be greatly appreciated. Thanks |
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.
Thanks for the work here - I think there are a few small things we can clear up before merging
Questions / nits left inline
This is a solid looking feature :)
Paul
|
||
func validateAwsCodePipelineArtifactStoreType(v interface{}, k string) (ws []string, errors []error) { | ||
value := v.(string) | ||
types := map[string]bool{ |
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.
I would change this to be if v.(string) != "S3"
then throw the error
Feel like overhead for a single value
func validateAwsCodePipelineEncryptionKeyType(v interface{}, k string) (ws []string, errors []error) { | ||
value := v.(string) | ||
types := map[string]bool{ | ||
"KMS": true, |
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.
I would change this to be if v.(string) != "KMS"
then throw the error
Feel like overhead for a single value
func validateAwsCodePipelineStageActionConfiguration(v interface{}, k string) (ws []string, errors []error) { | ||
value := v.(map[string]interface{}) | ||
types := map[string]bool{ | ||
"OAuthToken": true, |
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.
same as KMS and S3
conn := meta.(*AWSClient).codepipelineconn | ||
pipeline := expandAwsCodePipeline(d) | ||
params := &codepipeline.CreatePipelineInput{ | ||
Pipeline: pipeline, |
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.
I think, as expandAwsCodePipeline
func doesn't return an error, then we can just do it as follows:
Pipeline: expandAwsCodePipeline(d)
if err != nil { | ||
return fmt.Errorf("[ERROR] Error creating CodePipeline: %s", err) | ||
} | ||
d.SetId(*resp.Pipeline.Name) |
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.
is there a chance that resp.Pipeline
may be nil? If so, this will panic
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.
It does not seem like it, it should raise an error if the pipeline was not created. But I can add a check to be sure.
func resourceAwsCodePipelineUpdate(d *schema.ResourceData, meta interface{}) error { | ||
conn := meta.(*AWSClient).codepipelineconn | ||
|
||
pipeline := expandAwsCodePipeline(d) |
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.
Do you need to send the whole request back to AWS on update? Some of their APIs allow us to send just the values that change
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.
It appears I can't. Update takes a PipelineDeclaration which is the same as the create, it has a lot of required fields.
http://docs.aws.amazon.com/sdk-for-go/api/service/codepipeline/#UpdatePipelineInput
@stack72 @heimweh Made some adjustments, tests still passing.
|
So 1 more request - could you extend the test to show an update? P. |
@stack72 added a test for update and separated out the import test. We also found a bug where we rely on the name of the resource as ID (since we don't get any unique ID from AWS in the response). Solution simply: |
Tests are passing: $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSCodePipeline*'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/02/22 17:44:47 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSCodePipeline* -timeout 120m
=== RUN TestAccAWSCodePipeline_Import_basic
--- PASS: TestAccAWSCodePipeline_Import_basic (28.51s)
=== RUN TestAccAWSCodePipeline_basic
--- PASS: TestAccAWSCodePipeline_basic (45.71s)
PASS
ok github.com/hashicorp/terraform/builtin/providers/aws 74.244s |
Since we don't require a second pass, only do a read.
Hi both Code looks good to me - tests don't pass i'm afraid
P. |
Tests without $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSCodePipeline*'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/02/22 18:19:42 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSCodePipeline* -timeout 120m
=== RUN TestAccAWSCodePipeline_Import_basic
--- SKIP: TestAccAWSCodePipeline_Import_basic (0.00s)
import_aws_codepipeline_test.go:13: Environment variable GITHUB_TOKEN is not set
=== RUN TestAccAWSCodePipeline_basic
--- SKIP: TestAccAWSCodePipeline_basic (0.00s)
resource_aws_codepipeline_test.go:17: Environment variable GITHUB_TOKEN is not set
PASS
ok github.com/hashicorp/terraform/builtin/providers/aws 0.023s |
LGMT Thanks for that addition :)
|
* provider/aws: New resource codepipeline * Vendor aws/codepipeline * Add tests * Add docs * Bump codepipeline to v1.6.25 * Adjustments based on feedback * Force new resource on ID change * Improve tests * Switch update to read Since we don't require a second pass, only do a read. * Skip tests if GITHUB_TOKEN is not set
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Hello there, I'm taking over some work done by @heimweh who is on Paternity leave.
First time coding a resource for terraform, It's not very clean at the moment. But I just thought that I'd put this pull request up there so you know that I'm working on it. (Or if someone else is working on it and I'm wasting time on this)