-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(servicecatalog): Add Product Stack Asset Support #22143
Conversation
4d764ea
to
593cec0
Compare
Hi, |
@padaszewski That should automatically be supported.
|
@wanjacki |
593cec0
to
6079ef4
Compare
6079ef4
to
86b14f6
Compare
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.
Hi @wanjacki! Given this a quick read through with some initial comments.
packages/@aws-cdk/aws-servicecatalog/lib/product-stack-asset-bucket.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-servicecatalog/lib/product-stack-asset-bucket.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-servicecatalog/lib/product-stack-asset-bucket.ts
Outdated
Show resolved
Hide resolved
} | ||
|
||
/** | ||
* Fetch the expected S3 location of an asset. |
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.
this is doing more than fetch right? adds an asset to this.assets
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.
Updated to be a bit more descriptive.
|
||
this.assets = []; | ||
|
||
cdk.Aspects.of(this).add({ |
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.
what is the reasoning behind using cdk.Aspects
to run deploy assets? not questioning, just wondering.
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 can be done without Aspects I believe, but Aspects fits the use case and allows us to cleanly implement our use case as well as abstract the additional code to the new product-stack-asset-bucket
construct rather than modifying and adding additional code to product-stack
.
Pull request has been modified.
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 have a couple of big concerns with this PR.
- We need an integration test that tests creating a product with assets and provisioning a
product with assets. - I'm not sure about how you are currently handling the asset buckets. Each individual product will
get it's own asset bucket? What about having a single bucket that the user needs to create
themselves? A bucket per product seems like it will lead to more work on the consumer side (if
you want to provision product ABC then add a policy to your role with access to bucket ABC).
|
||
/** | ||
* The S3 bucket containing product stack assets. | ||
* @default - None |
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.
What does None
mean? If this is not provided are assets not supported?
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.
This class is the result of binding a Artifact Template into a Product.
In the event that it is not binding to a Product Stack (URL or local asset template instead), there is no asset bucket and no asset support.
In the event that they are binding a Product Stack, if they are not using assets, then the asset bucket will not be generated and will be undefined and there will be no asset bucket.
In any other case there is an asset bucket.
I will update to None - no assets are used in this product
as well.
/** | ||
* Product stack asset bucket. | ||
* | ||
* @default - None |
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 update the docstring to be more descriptive. As a user I want to know should I pass
something here or not? When would I want to provide my own bucket and what is the behavior if I
don't
/** | ||
* The asset bucket of a product created via product stack. | ||
* @atrribute | ||
* @default - None |
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.
Something like None - no assets are used in this product
/** | ||
* Name of s3 asset bucket deployed | ||
* | ||
* @default - None |
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 you can be more descriptive here since you know what the generated name will be (or atleast
the format).
* A Service Catalog product stack asset bucket, which is similar in form to an Amazon S3 bucket. | ||
* You can store multiple product stack assets and collectively deploy them to S3. | ||
*/ | ||
export class ProductStackAssetBucket extends Construct { |
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 this should extends s3.Bucket
.
if (!this.assetBucket) { | ||
const parentStack = (this.stack as ProductStack)._getParentStack(); | ||
this.assetBucket = new ProductStackAssetBucket(parentStack, `ProductStackAssetBucket${hashValues(this.stack.stackName)}`); | ||
} |
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'm not sure how I feel about the way we are creating the asset bucket here. What if we just created
the asset bucket by default as part of the product stack?
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 mean we create a ProductStackAssetBucket regardless of if the user is using an asset or not.
I don't that is a good idea since we would be creating resources that will not be needed (S3-deployment also deploys a lambda). Furthermore, a user could be unintentionally create a bunch of S3 Buckets (since it is one per product-stack) and fill up their S3 Bucket limit capacity.
} | ||
|
||
(this.stack as ProductStack)._setAssetBucket(this.assetBucket._getBucket()); | ||
return this.assetBucket._addAsset(_asset); |
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 this is where we should handle the asset deployment, rather than in the bucket construct.
@@ -16,7 +25,17 @@ export class ProductStackSynthesizer extends cdk.StackSynthesizer { | |||
} | |||
|
|||
public addFileAsset(_asset: cdk.FileAssetSource): cdk.FileAssetLocation { |
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.
public addFileAsset(_asset: cdk.FileAssetSource): cdk.FileAssetLocation { | |
public addFileAsset(asset: cdk.FileAssetSource): cdk.FileAssetLocation { |
protected addBucketPermissionsToSharedAccounts() { | ||
if (this.sharedAccounts.length > 0) { | ||
for (const bucket of this.assetBuckets) { | ||
bucket.grantRead(new iam.CompositePrincipal(...this.sharedAccounts.map(account => new iam.AccountPrincipal(account))), |
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.
How are you granting access on the other side? The IAM role that gets from these buckets needs
access to be granted access to the bucket in its princial policy.
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.
Addressed in my other comment, but there is not much more we can do. We made it as easy as possible but we don't have access to the accounts it is being shared with, it is up to the Admin to configure these spoke accounts.
@@ -1,8 +1,9 @@ | |||
import * as path from 'path'; |
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.
This integration test only tests half of the scenario. It confirms that we can publish to the
bucket, but how do we know that we can then deploy one of these products?
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.
The same can be said about any of the other existing integration test. There exist validation in Service Catalog to validate the template before it can be created but it can't check everything. We can't provision the product in CDK code and even then trying to provision it would probably fall in the scope of a provision-product construct.
I'm not sure if is the products job to check if a Product is provisionable, Service Catalog allows us to create a Product regardless of if its deployable or not. We also do our best in unit test to check the generated template is as expected.
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.
This is different though than existing functionality. In this PR we are adding functionality outside of service catalog. This PR is completely useless if the consumer cannot access the assets in the bucket and we have no test to assert that.
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.
Hey Cory, I refactored ProductStackAssetBucket to extend S3.Bucket as suggested as well as implemented the other comments.
I also added additional unit test to check Bucket Name and Bucket Policy Permissions are correct in template when shared.
If we can catch that the bucket is correct and the permissions are correct then the product should be deployable and the bucket should be acessable. If this is still not enough, please advise what what other test we can add (I don't think provisioning it is an option).
|
Pull request has been modified.
@wanjacki I would recommend going through the RFC process for this feature. There are a lot of design considerations that we are not yet agreed on. The biggest thing for me is that we have to consider the entire experience (publishing & consuming). |
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.
Putting back in request changes.
…nal unit test for bucket name and permission sharing.
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
+1 on this comment. I'm going to convert this into a draft until we have an approved RFC for this. |
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.
Putting in changes requested to accurately reflect status.
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error. |
Currently Assets are not supported in Product Stacks. Service Catalog has an unique use case where assets need to be shared cross account and sharing the entire CDK asset bucket is not ideal. Users can either create their own ProductStackAssetBucket or have one automatically generated for them based on their account Id and region. By using S3 Deployments we able to copy the assets to that bucket and share it when a portfolio is shared in Service Catalog.
More details can be found here: #20690. Closes #20690
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
Co-authored-by: Theron Mansilla[imanolympic]