Skip to content
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

Service Catalog Product resource added #13834

Closed
wants to merge 96 commits into from

Conversation

ahgittin
Copy link

This PR adds support for the aws_servicecatalog_product.

This is included in #13797 which adds multiple Service Catalog resources, but this PR has the changes for that one resource isolated for easier review, done in such a way this PR can be merged on its own. As noted in #13797 this builds on #4980 and includes it.

Review comments from those PRs have been incorporated here, and tests updated based on the advice on #13797. (I hope I've done it right and included all that are needed!)

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #13797

Closes #4980

Release note for CHANGELOG:

New Resource: `aws_servicecatalog_product`

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccTestAccAWSServiceCatalogProduct'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -count 1 -parallel 20 -run=TestAccAWSServiceCatalogProduct -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAWSServiceCatalogProduct_Basic
--- PASS: TestAccAWSServiceCatalogProduct_Basic (36.32s)
=== RUN   TestAccAWSServiceCatalogProduct_Tags
2020/06/19 00:55:03 DestroyEdgeTransformer: pruning unused resource node aws_s3_bucket.bucket (prepare state)
2020/06/19 00:55:03 DestroyEdgeTransformer: pruning unused resource node aws_s3_bucket_object.template1 (prepare state)
2020/06/19 00:55:03 DestroyEdgeTransformer: pruning unused resource node aws_servicecatalog_product.test (prepare state)
2020/06/19 00:55:03 DestroyEdgeTransformer: pruning unused resource node data.aws_region.current (prepare state)
--- PASS: TestAccAWSServiceCatalogProduct_Tags (74.98s)
=== RUN   TestAccAWSServiceCatalogProduct_updateProvisioningArtifactBasic
2020/06/19 00:55:55 DestroyEdgeTransformer: pruning unused resource node aws_s3_bucket_object.template1 (prepare state)
2020/06/19 00:55:55 DestroyEdgeTransformer: pruning unused resource node aws_servicecatalog_product.test (prepare state)
2020/06/19 00:55:55 DestroyEdgeTransformer: pruning unused resource node data.aws_region.current (prepare state)
2020/06/19 00:55:55 DestroyEdgeTransformer: pruning unused resource node aws_s3_bucket.bucket (prepare state)
--- PASS: TestAccAWSServiceCatalogProduct_updateProvisioningArtifactBasic (53.35s)
=== RUN   TestAccAWSServiceCatalogProduct_updateSourceBucketForceNew
2020/06/19 00:56:54 DestroyEdgeTransformer: pruning unused resource node data.aws_region.current (prepare state)
2020/06/19 00:56:54 DestroyEdgeTransformer: pruning unused resource node aws_s3_bucket.bucket (prepare state)
2020/06/19 00:56:54 DestroyEdgeTransformer: pruning unused resource node aws_servicecatalog_product.test (prepare state)
2020/06/19 00:56:54 DestroyEdgeTransformer: pruning unused resource node aws_s3_bucket_object.template1 (prepare state)
--- PASS: TestAccAWSServiceCatalogProduct_updateSourceBucketForceNew (59.42s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	225.364s
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/flatmap	0.307s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags	0.263s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/naming	0.224s [no tests to run]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/apigatewayv2/waiter	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/batch/equivalency	0.130s [no tests to run]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/ecs/waiter	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/eks/token	0.197s [no tests to run]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/guardduty/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/iam/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/kinesisanalytics/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/kms/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/neptune/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/rds/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/secretsmanager/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/servicediscovery/waiter	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/aws/internal/service/workspaces/waiter	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/tfawsresource	0.416s [no tests to run]
?   	github.com/terraform-providers/terraform-provider-aws/awsproviderlint	[no test files]
?   	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/helper/awsprovidertype/keyvaluetags	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/passes	0.748s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/passes/AWSAT001	0.588s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/passes/AWSR001	0.102s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/passes/AWSR002	0.942s [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/awsproviderlint/passes/fmtsprintfcallexpr	0.091s [no tests to run]

bw-intuit and others added 30 commits June 25, 2018 15:10
…t-and-pp

fix trivial conflicts where master has changed how resources are listed (in website and in aws/provider),
to reference servicecatalog_product in the right way

also revert the mode change against the servicecatalog_portfolio markdown
only pulling in the relevant provisioned-product changes
* create needs to block for completion, then the test (as written) will work in our account
* then we need product_portfolio_association and make the test work in any account (create a product, not hard-coded)
* then other TODOs marked in code
* master: (79 commits)
  Update CHANGELOG for hashicorp#8457
  resource/aws_ec2_tag: Finish implementation
  CodeArtifact new service support (hashicorp#13735)
  internal/keyvaluetags: Support servicediscovery and worklink (hashicorp#13732)
  tests/provider: Remove TravisCI (hashicorp#13730)
  update method params in web_acl test check
  Update CHANGELOG for hashicorp#12688
  Fix rebase change
  Fix docs
  Improve error message
  Apply review comments
  Refactor after rebase
  Apply review comments
  Apply changes based on review
  Format test config
  Fix failing build
  Add calculated wcus attribute
  Add documentation
  Add rule_group_reference_statement
  Add rate_based_statement
  ...
Match the same method used in other places within the provider to create idempotency tokens.
@ahgittin
Copy link
Author

This has been updated as per the 18 Aug notification to use the v2 sdk and remove aws.erb (fixing the conflicts), and also updating to conform to the stricter markdown checks.

Copy link
Collaborator

@DrFaust92 DrFaust92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments

Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that enum slices exist lets change this.
ValidateFunc: validation.StringInSlice(servicecatalog.ProductType_Values(), false),

Optional: true,
ForceNew: true,
Default: servicecatalog.ProvisioningArtifactTypeCloudFormationTemplate,
ValidateFunc: validation.StringInSlice([]string{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enums slice same as above


func resourceAwsServiceCatalogProductCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).scconn
input := servicecatalog.CreateProductInput{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can move all required argument inline and use Get instead of GetOk for them.

return fmt.Errorf("setting ProvisioningArtifact for product '%s' failed: %s", d.Id(), err)
}

// TODO budgets
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove these comments(open a separate issue for it) or add these as computed

Comment on lines +288 to +289
v, _ := d.GetOk("description")
input.Description = aws.String(v.(string))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input.Description = aws.String(d.Get("description").(string))

relevant for all the update uses later as well

}

// figure out what tags to add and what tags to remove
if d.HasChange("tags") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	if d.HasChange("tags") {
		o, n := d.GetChange("tags")

		input.AddTags = keyvaluetags.New(n).IgnoreAws().ServicecatalogTags()
		input.RemoveTags = aws.StringSlice(keyvaluetags.New(o).IgnoreAws().Keys())
	}

see portofolio resource tag update

Comment on lines +377 to +378
input := servicecatalog.DeleteProductInput{}
input.Id = aws.String(d.Id())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets put Id inline int the delete input struct

})
}

func TestAccAWSServiceCatalogProduct_tags(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to follow the example used in TestAccAWSServiceCatalogPortfolio_Tags for parity

return nil
}

func testAccAWSServiceCatalogProductConfig_basic(productSaltedName, bucketSaltedName, paSaltedName, tags string) string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove the tag from here and create a separate config for tags

* `name` - (Required) The name of the product.
* `owner` - (Required) The owner of the product.
* `product_type` - (Required) The type of product. Valid values: `CLOUD_FORMATION_TEMPLATE` or `MARKETPLACE`
* `provisioning_artifact` - (Required) The configuration of the provisioning artifact. This object supports the following:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets break down config blocks to a separate doc block, see cognito_user_pool for example. it will make reading easier.

Base automatically changed from master to main January 23, 2021 00:58
@breathingdust breathingdust requested a review from a team as a code owner January 23, 2021 00:58
@YakDriver YakDriver self-assigned this Feb 17, 2021
@YakDriver
Copy link
Member

@ahgittin Thank you for your work on this PR! I will be working on this before long. In order to expedite the process, I will likely make some changes. Make sure that you have checked the box "Allow edits from maintainers." (Don't worry though, you will receive all credit for your contribution and code!) Also, please coordinate with us before making any commits to this branch. Again, thank you for your help and we look forward to this popular addition to the AWS provider!

@YakDriver YakDriver closed this Mar 5, 2021
@YakDriver YakDriver reopened this Mar 5, 2021
@YakDriver
Copy link
Member

@ahgittin @cloudsoft Thank you very much for all your work on this PR! I'm excited to work with you on this. However, in order to work with this PR, I need two things:

  1. You must check the "Allow edits from maintainers" box. It is currently not checked. (Only @cloudsoft will be able to check the box since the fork with this branch is in the @cloudsoft repo.)
  2. Currently there are 96 commits which add, remove, add again, remove again, add again, change file modes, etc. All 96 commits need to be squashed into a single commit to proceed.

Since we look forward to adding this feature to the AWS Provider, we need you to make these changes by March 11, 2021. If you are unable to do this, we understand and thank you for your work. However, we will not be able to use this contribution.

@YakDriver YakDriver added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 5, 2021
@ahgittin
Copy link
Author

@YakDriver great to hear this. However there are a few stumbling blocks:

(1) GitHub does not allow "Allow edits from maintainers" on this PR. I think it is due to isaacs/github#1681 .
(2) Squashing the commits means that the other contributors on whose work this was built will show up as contributors. But it is an ugly history so that might be worth it.
(3) As there are multiple PRs that have some sequential dependencies -- a painful split done at the request of another reviewer, to make each resource its own PR -- but this means squashing one will of course make the others non-mergeable with it

It might be best to open a new PR with all the contributed Service Catalog resources, squashed into a single commit to resolve (3). I can do this from my personal github instead of our organization which will resolve (1). Re (2) I will note the various contributors and provenance in the squashed commit message.

@ghost ghost removed waiting-response Maintainers are waiting on response from community or contributor. labels Mar 10, 2021
@YakDriver
Copy link
Member

YakDriver commented Mar 11, 2021

@ahgittin I'm very glad to hear from you!

Might I suggest cherry picking? If you cherry pick to your own branch, you could squash many of the commits without losing contributions possibly. While I've done a lot of squashing, I've not squashed others commits so I'm not 100% sure it will maintain association of original contributor. But, if the history could be reduced to significantly fewer commits, that would be tremendous. It does not need to be 1.

Squash Plan A: If the history has a consecutive group of 10 commits by the same authors, if you squash them, does it maintain the authorship? This would be ideal because the contributor line count would be maintained and the number of commits would be reduced.

Squash Plan B: If squashing a group of commits does not maintain authorship, another possibility would be to maintain 1 (or a few) commits for each of the authors. The line count of each contributor would not be accurate but they would still show up as contributors.

As for separate PRs versus a single one, it is often helpful to have them separated. The reviewer was absolutely correct that that is the normal practice. However, in this case, it has become difficult to tell which PR is dependent on which and which version of a given resource in which PR is the "latest and greatest." As a result, let's go against the normal approach and try a single PR/branch.

To sum up, can we agree on this as a path forward?

  1. Move all the resources to a single branch in your personal repository.
  2. Significantly condense the history to preserve authorship as much as possible (plan A if possible, plan B if not).
  3. I'll look through the single branch and see how feasible it will be work on it all at once.

Let me know if you have concerns. Also, as we are anxious to move forward, what does your timeframe look like?

@YakDriver YakDriver added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 11, 2021
@ahgittin
Copy link
Author

ahgittin commented Mar 11, 2021 via email

@ghost ghost removed waiting-response Maintainers are waiting on response from community or contributor. labels Mar 11, 2021
@ahgittin
Copy link
Author

@YakDriver ^ Completed in #18074 .

This can be closed in favour of that.

@YakDriver
Copy link
Member

@ahgittin In an abundance of caution, let's leave this open for a short time while I look over #18074. Thanks for your work on this! My apologies for the delay in getting back to you. As you can imagine, there's a lot going on.

@ghost
Copy link

ghost commented Apr 30, 2021

This has been released in version 3.38.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/servicecatalog Issues and PRs that pertain to the servicecatalog service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants