Skip to content

Instantly share code, notes, and snippets.

@mgjam
Created October 21, 2021 08:34
Show Gist options
  • Save mgjam/23164b6bd725fde4763447be1a749643 to your computer and use it in GitHub Desktop.
Save mgjam/23164b6bd725fde4763447be1a749643 to your computer and use it in GitHub Desktop.
export class ExportingStack extends Stack {
public readonly bucket: Bucket;
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
this.bucket = new Bucket(this, 'ExportedBucket');
// Create the output to break the dependency conflict
const output = new CfnOutput(this, 'myTempOutput', {
value: 'arn:aws:s3:::exp-exportedbucket5c9669b4-1rik6ssb94d7x',
exportName: 'exp:ExportsOutputFnGetAttExportedBucket5C9669B4ArnA5E36DA6'
});
// Override autogenerated logical Id to match the previously deleted output
output.overrideLogicalId('ExportsOutputFnGetAttExportedBucket5C9669B4ArnA5E36DA6');
}
}
export interface ImportingStackProps extends StackProps { bucket: Bucket }
export class ImportingStack extends Stack {
public readonly output: CfnOutput;
constructor(scope: Construct, id: string, props: ImportingStackProps) {
super(scope, id, props);
this.output = new CfnOutput(this, 'bucketDomainName', {
value: props.bucket.bucketDomainName
});
}
}
const exportingStack = new ExportingStack(app, 'exp', {});
const importingStack = new ImportingStack(app, 'imp', {
bucket: exportingStack.bucket
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment