https://pulumi.com logo
Docs
Join the conversationJoin Slack
Channels
announcements
automation-api
aws
azure
blog-posts
built-with-pulumi
cloudengineering
cloudengineering-support
content-share
contribex
contribute
docs
dotnet
finops
general
getting-started
gitlab
golang
google-cloud
hackathon-03-19-2020
hacktoberfest
install
java
jobs
kubernetes
learn-pulumi-events
linen
localstack
multi-language-hackathon
office-hours
oracle-cloud-infrastructure
plugin-framework
pulumi-cdk
pulumi-crosscode
pulumi-deployments
pulumi-kubernetes-operator
pulumi-service
pulumiverse
python
registry
status
testingtesting123
testingtesting321
typescript
welcome
workshops
yaml
Powered by Linen
typescript
  • w

    white-balloon-205

    05/10/2019, 8:06 PM
    https://pulumi-community.slack.com/archives/C84L4E3N1/p1557515255363100?thread_ts=1557514564.363000&cid=C84L4E3N1
  • s

    salmon-account-74572

    05/10/2019, 9:05 PM
    OK, I'll start the TS questions. (Forgive my potentially incorrect terminology; gently correct me where needed.) I understand that properties of a class like
    aws.ec2.Instance
    are of type Input. How does one take the result of a function like
    aws.getAmi
    (which is a Promise, AIUI) and use it to specify a value for a property?
    b
    o
    • 3
    • 5
  • o

    orange-tailor-85423

    05/10/2019, 10:18 PM
    ready for some gross looking TS?
    😁 1
  • o

    orange-tailor-85423

    05/10/2019, 10:19 PM
    set the channel topic: All Typescript all the time! Noob friendly - no dumb questions.
    😆 1
  • o

    orange-tailor-85423

    05/10/2019, 10:19 PM
    set the channel topic: All Typescript all the time! Noob friendly - there are no dumb questions.
  • o

    orange-tailor-85423

    05/10/2019, 10:21 PM
    Ok so we are trying to decouple a hard dependency in how we run some tests so not depend on a
    pulumi up
    to generate our config. So far I’ve got a pre-commit hook:
  • o

    orange-tailor-85423

    05/10/2019, 10:21 PM
    -.txt
  • o

    orange-tailor-85423

    05/10/2019, 10:21 PM
    Attempting to use ts-node to run arbitrary TS files
  • o

    orange-tailor-85423

    05/10/2019, 10:21 PM
    here’s what it’s running:
  • o

    orange-tailor-85423

    05/10/2019, 10:22 PM
    (forgive all the console logging)
  • o

    orange-tailor-85423

    05/10/2019, 10:22 PM
    -.ts
  • o

    orange-tailor-85423

    05/10/2019, 10:22 PM
    We are leveraging the node config package to apply per environment ‘transforms’ on our default config. Works flawlessly for our pulumi deployments.
  • o

    orange-tailor-85423

    05/10/2019, 10:23 PM
    but what I want to do is pre-generate the resolved merge of the default and the environment configs and have them in the repo. Then when the test container runs, it’s got a per environment config json object ready to use and we select it via a simple env variable passed to the container
  • o

    orange-tailor-85423

    05/10/2019, 10:24 PM
    the code above mostly works and generates the json files. However it’s creating unique files but they all have the same contents namely, the config of our ‘alpha’ environment (the first one).
  • o

    orange-tailor-85423

    05/10/2019, 10:26 PM
    output of console logging:
  • o

    orange-tailor-85423

    05/10/2019, 10:27 PM
    -.ts
  • o

    orange-tailor-85423

    05/10/2019, 10:29 PM
    so I’m sure it’s something to do with a single process or invocation or something
  • g

    glamorous-printer-66548

    05/11/2019, 5:33 AM
    @orange-tailor-85423 Before we get to your actual issue just 2 quick remarks: 1. Please do yourself and your colleagues a favor and don’t name variables
    c
    or any other single character 😄. It just makes reading the code harder even if it’s somewhat clear from the surrounding context what the c stands for (but consumes more brain CPU :-P). In your example I would call this variable
    configFileName
    instead. 2. You can turn
    import fs = require('fs');
    into
    import * as fs from 'fs'
    . Just looks more ES6 native 😉 Coming to your actual problem: In line 15 you’re loading the merged config by calling require(‘config’). This will load the merged config based on your environment variables during the first .forEach loop iteration. However in the second loop iteration - despite you having changed the environment variables - the
    require('config')
    call will return exactly the same thing as in the first one. In general in node.js multiple calls of require(‘asdf’) will always return the exact same thing (this also applies to ES6 imports
    import ... from 'asdf'
    for that matter). This is described in further detail here: https://nodejs.org/api/modules.html#modules_caching . I haven’t tried it out myself but it looks like you should be able to use https://github.com/lorenwest/node-config/wiki/Using-Config-Utilities#loadfileconfigsdirectory (e.g.
    require('config').util.loadFileConfigs(path.join(__dirname, 'config'))
    instead of the plain
    require('config')
    to load the merged config without experiencing the caching problem.
  • f

    few-dog-41530

    05/15/2019, 3:49 PM
    Hello!
  • f

    few-dog-41530

    05/15/2019, 3:49 PM
    I am trying to deploy google cloud functions in typescript
  • f

    few-dog-41530

    05/15/2019, 3:50 PM
    But pulumi does not seem to have access to the private npm package of my organization. Can someone please help?
  • w

    white-balloon-205

    05/15/2019, 3:52 PM
    What error do you see?
  • f

    few-dog-41530

    05/15/2019, 3:58 PM
    Cannot access npm package
  • f

    few-dog-41530

    05/15/2019, 3:59 PM
    which is a private package created for my organization @org/private_package
  • w

    white-balloon-205

    05/15/2019, 4:01 PM
    I mean, what command are you running and what output are you seeing? As far as I’m aware, Pulumi does nothing to specifically prevent using a private NPM package, but you will have to be authenticated as normal. In fact, I don’t believe Pulumi even invokes NPM on your behalf, so I’d be surprised if a Pulumi cli invocation led to this error.
  • f

    few-dog-41530

    05/15/2019, 4:03 PM
    I run
    pulumi up
    locally
  • f

    few-dog-41530

    05/15/2019, 4:04 PM
    and I get a
    npm 404 error: cannot find @org/private...
    w
    • 2
    • 3
  • f

    few-dog-41530

    05/15/2019, 4:05 PM
    I can add packages via yarn or npm locally
  • f

    few-dog-41530

    05/15/2019, 4:10 PM
    let me delete my local
    npm_modules
    folder and try to install locally again
  • f

    few-dog-41530

    05/15/2019, 4:14 PM
    no issues running yarn
Powered by Linen
Title
f

few-dog-41530

05/15/2019, 4:14 PM
no issues running yarn
View count: 1