-
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
Service Catalog: Product Stack Assets S3 Keys are not present in Product template output #23560
Comments
@wanjacki Hope is okay when I ping You to have a look at this |
@padaszewski Likely does not help but does setting an outdir directly on your app directly do anything?
|
@wanjacki #!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import {pipelines, RemovalPolicy, Stack, Stage, StageProps} from 'aws-cdk-lib';
import {Construct} from "constructs";
import {CodePipeline} from "aws-cdk-lib/pipelines";
import {Bucket} from "aws-cdk-lib/aws-s3";
import {
CloudFormationProduct,
Portfolio,
ProductStack,
ProductStackHistory
} from "aws-cdk-lib/aws-servicecatalog";
const app = new cdk.App({outdir: 'cdk.out'},);
class PipelineStack extends Stack {
constructor(scope: Construct, id: string) {
super(scope, id)
const pipeline = new CodePipeline(this, this.stackName, {
pipelineName: this.stackName,
synth: new pipelines.ShellStep('Synth', {
input: pipelines.CodePipelineSource.connection('owner/repo', 'prod', {
connectionArn: 'arn:aws:codestar-connections:eu-west-1:123456789123:connection/some-uuid',
}),
commands: ['some command'],
}),
})
const portfolioWave = pipeline.addWave('DeployPortfolios')
const tenantsExamples = ['tenant1', 'tenant2', 'tenant3']
tenantsExamples.forEach((tenant) => {
portfolioWave.addStage(
new PortfolioStage(this, `tenant-portfolio-${tenant}-prod`, {
tenantName: tenant
}),
)
})
}
}
interface PortfolioStageProps extends StageProps {
readonly tenantName: string
}
class PortfolioStage extends Stage {
constructor(scope: Construct, id: string, props: PortfolioStageProps) {
super(scope, id, props)
const portfolioStack: Stack = new Stack(this, 'stk')
new PortfolioConstruct(portfolioStack, 'ctk', {
tenantName: props.tenantName
})
}
}
interface PortfolioConstructProps {
readonly tenantName: string
}
class PortfolioConstruct extends Construct {
constructor(scope: Construct, id: string, props: PortfolioConstructProps) {
super(scope, id)
const testAssetBucket = new Bucket(this, 'TestAssetBucket', {
bucketName: 'test-asset-bucket',
})
const productStack = new ProductStack(this, 'MyProductStack', {
assetBucket: testAssetBucket,
})
const testBucketAutoDelete = new Bucket(productStack, 'testBucketAutoDelete', {
bucketName: 'test-bucket-auto-delete',
autoDeleteObjects: true,
removalPolicy: RemovalPolicy.DESTROY,
})
const psh = new ProductStackHistory(this, 'psh', {
productStack: productStack,
currentVersionName: 'v1',
currentVersionLocked: false,
validateTemplate: true,
directory: 'version-snapshots',
})
const product = new CloudFormationProduct(this, `${props.tenantName}-CfnProduct`, {
productName: 'product name',
owner: 'product owner',
productVersions: [psh.currentVersion()],
})
const portfolio = new Portfolio(this, 'port', {
displayName: 'portfolio',
providerName: 'provider',
})
portfolio.shareWithAccount('123456789123')
portfolio.addProduct(product)
}
}
new PipelineStack(app, 'this-iss-long-pipeline-stack-name') |
Besides that I would like to reuse the Asset Bucket in each PortfolioStage. Is that possible? I tried to create the Asset Bucket in the PipelineStack but this leads to cross stage Errors while synthing. Any cool idea for that? |
Hint: I found out, that the asset name is const s3Filename = asset.fileName?.split('asset.')[1] + '.zip'; Or to use a appropriate RegExp. The question however is why some assets begin with |
@padaszewski I will put in a fix for this. |
Not sure how we can get around this. You might be able to use a referenced bucket |
@wanjacki |
#23580) Currently when assets are nested in a directory, ProductStack is unable to parse the fileName and produces an incorrect template. Since `asset.fileName` is the relative to the root of the cloud assembly, in which this asset source resides, we need to call `path.basename` in order to get the actual name of the file before parsing it to generate the `s3Filename` More details found in #23560 ---- ### All Submissions: * [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
I assume this should have been fixed in #23580 Closing now. Feel free to re-open if it's still relevant. |
|
Describe the bug
Hi,
I'm implementing the Product Stack Assets feature in combination with ProductStackHistory into our app and I faced quite a strange behavior. When I play around in the sandbox everything works fine and I get the desired output, however if I switch to our production code and try to use this feature then the S3 Key of the Function is missing.
Expected Behavior
The product template has a Function with following properties (as expected):
Metadata:
Current Behavior
In the sandbox works correct, however in production code I get this output in every template and function (S3Key):
In the metadata it seems to be recognized:
Asset path metadata value looks different comparing to sandbox.
Reproduction Steps
I literally copied the whole sandbox code into the production app so I should get multiple and exactly the same product templates.
Again, in an empty CDK App everything works good. Can it be that this feature is some kind of bugged when the structure of the app is deeply nested or the path are long?
Our's looks like following:
app -> pipelines -> waves -> stages -> stacks -> (constructs) -> product stacks
The output product template paths in
cdk.out
are also quite long:assembly-56chars/75chars.product.template.json
I do not have any other idea on how to debug this. Any ideas on how to proceed?
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.59.0 (build b24095d)
Framework Version
No response
Node.js Version
v16.15.0
OS
Windows
Language
Typescript
Language Version
TypeScript (4.9.4)
Other information
No response
The text was updated successfully, but these errors were encountered: