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

(assets): Make stack available as an asset #16153

Closed
2 tasks
0xjjoyy opened this issue Aug 20, 2021 · 7 comments
Closed
2 tasks

(assets): Make stack available as an asset #16153

0xjjoyy opened this issue Aug 20, 2021 · 7 comments
Assignees
Labels
@aws-cdk/assets Related to the @aws-cdk/assets package feature-request A feature should be added or improved.

Comments

@0xjjoyy
Copy link

0xjjoyy commented Aug 20, 2021

Make stack available as an asset in another stack, as the synthesized file doesn't exist when the other stack needs it to sythensize it's stack.

Use Case

AWS Config conformance packs need the cloudformation template
https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-config.CfnOrganizationConformancePack.html

Proposed Solution

Referencing #11896

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@0xjjoyy 0xjjoyy added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 20, 2021
@github-actions github-actions bot added the @aws-cdk/assets Related to the @aws-cdk/assets package label Aug 20, 2021
@kichik
Copy link

kichik commented Aug 22, 2021

CDK Pipelines do something like that. I believe they use Stage.synth() which generates a cloud assembly. A cloud assembly contains and gives access to your template and other assets.

@amirfireeye
Copy link
Contributor

Here is where that code lives

public static fromStage(stage: cdk.Stage, props: StageDeploymentProps = {}) {
const assembly = stage.synth();
if (assembly.stacks.length === 0) {
// If we don't check here, a more puzzling "stage contains no actions"
// error will be thrown come deployment time.
throw new Error(`The given Stage construct ('${stage.node.path}') should contain at least one Stack`);
}
const stepFromArtifact = new Map<CloudFormationStackArtifact, StackDeployment>();
for (const artifact of assembly.stacks) {
const step = StackDeployment.fromArtifact(artifact);
stepFromArtifact.set(artifact, step);
}
for (const artifact of assembly.stacks) {
const thisStep = stepFromArtifact.get(artifact);
if (!thisStep) {
throw new Error('Logic error: we just added a step for this artifact but it disappeared.');
}
const stackDependencies = artifact.dependencies.filter(isStackArtifact);
for (const dep of stackDependencies) {
const depStep = stepFromArtifact.get(dep);
if (!depStep) {
throw new Error(`Stack '${artifact.id}' depends on stack not found in same Stage: '${dep.id}'`);
}
thisStep.addStackDependency(depStep);
}
}
return new StageDeployment(Array.from(stepFromArtifact.values()), {
stageName: stage.stageName,
...props,
});
}

@peterwoodworth peterwoodworth removed the needs-triage This issue or PR still needs to be triaged. label Oct 5, 2021
@peterwoodworth
Copy link
Contributor

Thanks for responding guys!

@github-actions
Copy link

github-actions bot commented Oct 5, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@0xjjoyy
Copy link
Author

0xjjoyy commented Oct 6, 2021

I'm not sure why this is closed @peterwoodworth ? Is the feature implemented?

@peterwoodworth
Copy link
Contributor

Sorry, I'm not sure what makes this feature request distinct from the one that was linked #11896. Are these not the same requests?

@peterwoodworth
Copy link
Contributor

@0xjjoyy please ping me again if you can distinguish what's unique about this feature request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/assets Related to the @aws-cdk/assets package feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

5 participants