let’s say I’m deploying a React app that needs to ...
# general
g
let’s say I’m deploying a React app that needs to be built before deployed… anybody maybe managed to embed the build step into the Pulumi (TS) code maybe?
the problem I’m having is the following.. I’m building the React app before deploying with pulumi.. but… my React app code relies on a Amazon Cognito User Pool Client ID… therefore, on first deploy, the infra needs to be deployed, and only then the react app can be built / deployed, because only then I can pass the client ID to my react app as an env variable
note that, in React world, env vars values are actually baked into the built code.. which is different from, say, Lambda fns, which can have env var values sent via its Environment Variables option, and they are fetched in runtime
all in all, in an ideal scenario… the first deploy should go like 1. deploy user pool client 2. build the app (user pool client ID is correctly baked into the app code) 3. proceed with deploying the app and other resources
BTW React app is hosted on S3.. so yeah, a bucket deployment will also happen before the React app build is uploaded to it.. but yeah, no worries here, all works fine (because the React app code doesn’t rely on a S3 bucket balue, for example its ID or public URL)
c
You could look at the Pulumi Automation API to orchestrate that deployment. https://www.pulumi.com/docs/guides/automation-api/
The S3 bucket for example, is that bucket going to be used for any other purpose. You might be able to pull the management of the bucket into a shared infra project as it has a different lifecycle than the application you are deploying and the bucket might not need to be created by the app deployment
g
thanks for the feedback @colossal-vr-62639
at the moment, S3 is really not an issue, only the fact that the React app is being built before being deployed, where deployment includes the user pool, on which the React application depends..
so, it’s like: 1. react app build 2. new user pool client deploy 3. react app deploy to s3
but it should be
1. new user pool client deploy 2. react app build 3. react app deploy to s3
the build needs to happen during the deployment, and that was the reasoning behind the question I initially asked:
anybody maybe managed to embed the build step into the Pulumi (TS) code maybe?
b
Well it needs to happen during your concept of a deployment but it doesn’t need to happen during Pulumi’s concept of a deployment. Consider if step 1 and step 3 were separate Pulumi projects that could be pulumi deployed independently. Otherwise I think Automation API would be the way to go.
👍 2
g
thanks guys for your responses, much appreciated! 🍻