https://pulumi.com logo
#general
Title
# general
c

cold-coat-35200

07/31/2019, 7:14 AM
hi, I have an issue with pulumi typescript, when running
pulumi up
on the master branch without any change, it wants to delete all of my resources, looks like a caching issue with ts compiling, because I added log messages to the code and none of them appeared, deleted the code from index.ts and created only 1 resource, but after an up it only shows the old resource deletions, nothing about the new one, then I cloned our repo to a different directory, where pulumi works as expected, does not want change anything I wasn't able to figure out how pulumi compiles my typescript files and where stores the compiled js files. How can I solve this problem without deleting the whole git repo and clone again? (btw, I'm not sure that would be a solution in case if I clone to the same path)
b

broad-dog-22463

07/31/2019, 7:41 AM
@cold-coat-35200 can you clarify step by step what has happened here? I can try and work through this
c

cold-coat-35200

07/31/2019, 8:10 AM
I don't think you can reproduce this, I just did my daily work, run an up, which wanted to change some resource, I pressed no to that, run a refresh successfully then run up again and this time pulumi wanted to delete all my files I switched to another stack in the same project and the same thing happened, so it's not a stack related issue Pretty sure that somehow pulumi does not see my ts because it does not pick up any change in the index.ts file and that's why it want to delete all resources
b

broad-dog-22463

07/31/2019, 8:18 AM
It definitely will see the changes to index.ts - the model allows for us to make changes on the fly and Pulumi up to pick them up immediately
When you run the up and it tries to delete everything, can you grab the details and paste it here for me? I can have a look and see
c

cold-coat-35200

07/31/2019, 9:19 AM
for 216 resource? that would be a lot πŸ˜„ I can send you in private, but could you tell me first how pulumi compile the ts files and where store the compiled files? in tsconfig.json I see
"outDir": "bin",
, but I wasn't able to find a bin dir anywhere in my project tree
I figured out the problem, OMG πŸ˜„ πŸ˜„ πŸ˜„ so, before a refresh, I usually do a stack export, just in case, anything goes wrong, I did the same this time too to a file, named
dev.json
our main index file looks like this:
Copy code
import * as pulumi from '@pulumi/pulumi'
import { RunError } from '@pulumi/pulumi/errors'

const stack = pulumi.getStack()
let output

if (stack === 'dlv-dev' || /^dlv-sbx([1-3])?$/.test(stack)) {
  output = require('./dev')
} else if (stack === 'dlv-prod') {
  output = require('./prod')
} else {
  throw new RunError(`Invalid stack: ${stack}`)
}

module.exports = output
I changed
require('./dev')
to
require('./dev/index.ts')
and magically pulumi worked again, didn't want to delete everything, I became suspicious πŸ™‚ I added this
console.log(require.resolve('./dev'))
to index.ts, the output:
/home/ncsibra/dev/prmrgt-infra/pulumi/dliver/dev.json
πŸ˜„ Ok, that json file does not contain any resource definition, so pulumi was right about deleting everything πŸ˜„ After renaming
dev.json
require
picked up the
index.ts
file in the
dev
folder, so pulumi saw my resource definitions again Lesson learned, sorry about the false alarm πŸ™‚
b

broad-dog-22463

07/31/2019, 10:18 AM
It’s all ok ;) as long as nothing bad!