terraform-cdk
terraform-cdk copied to clipboard
Provide Common Temporary Directory
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue 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 issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
I've been repeating this pattern across several test projects:
const tmpWorkDir = path.join(process.cwd(), 'tmp', 'build', 'data-sources')
fs.mkdirSync(tmpWorkDir, { recursive: true })
const filePath = path.join(tmpWorkDir, `${name}-data-source.js`)
That's useful whenever a user wants to write generated files to disk and use it in conjunction with TerraformAsset
.
It would be nice to have something like:
const tmpFile = new TmpFile(this, 'my-file', {
content: `my file contents`
})
new TerraformAsset(this, 'data-source-asset', {
path: tmpFile.path,
type: AssetType.FILE,
});
// or perhaps even just like this
new TmpFile(this, 'my-file', {
content: `my file contents`
distributeAs: AssetType.FILE
})
References
Sounds interesting!
Just a random idea: Why not extending TerraformAsset (or composing with it in some other way), so that the TmpFile itself would "be the Asset". Or is there any use case to just writing the TmpFile?
How I would imagine using it:
const tmpFile = new TmpFile(this, 'file', {
content: `<html><body>Welcome to my empty website</body></html>`
})
new S3BucketObject(this, "index", {
bucket: bucket.bucket,
key: 'index.html',
source: tmpFile.path,
});
Why not extending TerraformAsset (or composing with it in some other way), so that the TmpFile itself would "be the Asset".
I think that would make sense indeed 👍
Perhaps it's more something like GeneratedFile
or FileGenerator
?
InlineFile
? 😄 (I'm not 100% satisfied with this name though)
InlineFile
? 😄
Hm, not bad - I like that 👍
@skorfmann @ansgarm can you guys plz explain little bit more about this issue. I am interested in working on it.