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

worried-city-86458

11/13/2019, 10:44 PM
@crooked-jelly-50877 you could try using Visual Studio Code Remote Containers (https://code.visualstudio.com/docs/remote/containers) That's what I'm using on Windows for a consistent Ubuntu environment and it's been great
I set up my docker image with bash completion as follows:
Copy code
FROM ubuntu:bionic

# Install packages
RUN apt-get update \
    && apt-get install -y bash-completion curl gnupg lsb-release \
    && mkdir -p /etc/bash_completion.d \
    && curl -fsSL <https://deb.nodesource.com/gpgkey/nodesource.gpg.key> | apt-key add - \
    && echo "deb <https://deb.nodesource.com/node_12.x> $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/node.list \
    && curl -fsSL <https://dl.yarnpkg.com/debian/pubkey.gpg> | apt-key add - \
    && echo "deb <https://dl.yarnpkg.com/debian/> stable main" | tee /etc/apt/sources.list.d/yarn.list \
    && apt-get update \
    && apt-get install -y nodejs yarn \
    && npm completion > /etc/bash_completion.d/npm \
    && curl -fsSL <https://raw.githubusercontent.com/dsifford/yarn-completion/master/yarn-completion.bash> > /etc/bash_completion.d/yarn \
    && rm -rf /var/lib/apt/lists/*

# Install kubectl; <https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-via-curl>
RUN curl -fsSL <https://storage.googleapis.com/kubernetes-release/release/v1.14.7/bin/linux/amd64/kubectl> > /usr/local/bin/kubectl \
    && chmod +x /usr/local/bin/kubectl \
    && kubectl completion bash > /etc/bash_completion.d/kubectl \
    && echo "alias k='kubectl'\ncomplete -o default -F __start_kubectl k" >> ~/.bashrc \
    && kubectl version --client --short

# Install aws iam authenticator; <https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html>
RUN curl -fsSL <https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.4.0/aws-iam-authenticator_0.4.0_linux_amd64> > /usr/local/bin/aws-iam-authenticator \
    && chmod +x /usr/local/bin/aws-iam-authenticator

# Install helm; <https://github.com/helm/helm/blob/master/docs/install.md>
RUN curl -fsSL <https://get.helm.sh/helm-v2.16.1-linux-amd64.tar.gz> | tar -xzO linux-amd64/helm > /usr/local/bin/helm \
    && chmod +x /usr/local/bin/helm \
    && helm completion bash > /etc/bash_completion.d/helm \
    && helm init --client-only \
    && helm version --client --short

# Install Pulumi
ENV PULUMI_VERSION=1.5.2 PULUMI_SKIP_UPDATE_CHECK=true

RUN curl -fsSL <https://get.pulumi.com> | bash -s -- --version $PULUMI_VERSION \
    && sed -i -e '/# add Pulumi to the PATH/,/export PATH=/d' ~/.bashrc \
    && mv ~/.pulumi/bin/* /usr/local/bin \
    && pulumi gen-completion bash > /etc/bash_completion.d/pulumi \
    && echo "alias p='pulumi'\ncomplete -o default -F __start_pulumi p" >> ~/.bashrc \
    && pulumi version

ENTRYPOINT [ "pulumi" ]
`.devcontainer/devcontainer.json`:
Copy code
{
  "name": "Pulumi",
  "dockerFile": "Dockerfile",
  "context": "..",
  "runArgs": [
    "-v",
    "/var/run/docker.sock:/var/run/docker.sock",
    "-e",
    "AWS_ACCESS_KEY_ID",
    "-e",
    "AWS_SECRET_ACCESS_KEY",
    "-e",
    "AWS_REGION",
    "-e",
    "PULUMI_ACCESS_TOKEN"
  ],
  "settings": {
    "terminal.integrated.shell.linux": null
  },
  "extensions": [
    "ms-vscode.vscode-typescript-tslint-plugin"
  ]
}
c

crooked-jelly-50877

11/13/2019, 10:54 PM
Interesting. I gather that the .pulumi directory is always in the container, and you do not map it to the users host .pulumi?
Do they lose history, etc. if they exit the container?
w

worried-city-86458

11/13/2019, 10:56 PM
The source is in my local directory, on Windows, and appears in the container when I initiate remote containers mode.
I can edit in VS Code and I see the change locally; i.e. it's a host mounted volume, or at least behaves like one.
You can use the same trick for remote SSH or cloud shells
One last thing, for the bash completion to work, add the following to your VS Code settings:
Copy code
{
  "terminal.integrated.shellArgs.linux": [
    "-l"
  ]
}
c

crooked-jelly-50877

11/13/2019, 11:02 PM
I gather the plugins would be installed as Linux, and the user would always have to use pulumi from the container, they could not run the native Windows one?
w

worried-city-86458

11/13/2019, 11:02 PM
Re
.pulumi
, I move the binary to
/usr/local/bin
in my image
c

crooked-jelly-50877

11/13/2019, 11:02 PM
(which might be fine - we would need to explain this to avoid confusion)
Are your plugins/ in your local dir Linux or Windows binaries?
w

worried-city-86458

11/13/2019, 11:06 PM
Not sure, I haven't dealt with plugins directly.
Copy code
root@9df9b591f799:~# ll -R ~/.pulumi
/root/.pulumi:
total 16
drwxr-xr-x 3 root root 4096 Nov 13 17:53 ./
drwx------ 1 root root 4096 Nov 13 19:00 ../
drwx------ 2 root root 4096 Nov 13 17:53 bin/

/root/.pulumi/bin:
total 8
drwx------ 2 root root 4096 Nov 13 17:53 ./
drwxr-xr-x 3 root root 4096 Nov 13 17:53 ../
What am I looking for?
c

crooked-jelly-50877

11/13/2019, 11:08 PM
not sure why you dont have a .pulumi/plugins/
Copy code
ls -lR plugins/
plugins/:
total 4
drwx------ 2 warren_strange warren_strange 4096 Nov 13 14:45 resource-gcp-v1.3.0
plugins/resource-gcp-v1.3.0:
total 84604
-rwxr-xr-x 1 warren_strange warren_strange 86634321 Nov 13 14:45 pulumi-resource-gcp
where are all your credentials.json, history, etc.
w

worried-city-86458

11/13/2019, 11:14 PM
Creds for aws? I use env vars injected into the container
Same with Pulumi token
It's basically a portable dockerized dev env
c

crooked-jelly-50877

11/13/2019, 11:29 PM
ok, and you use the pulumi backend state service I assume -so the container does not need to remember state?
w

worried-city-86458

11/13/2019, 11:38 PM
Yes
c

crooked-jelly-50877

11/14/2019, 12:21 AM
OK - Iā€™m checking out the vscode plugin now šŸ˜‰
Thanks for the tip