Skip to content

Fix/working example with env vars#611

Open
DavidHoenisch wants to merge 3 commits intodirien:mainfrom
DavidHoenisch:fix/working-example-with-env-vars
Open

Fix/working example with env vars#611
DavidHoenisch wants to merge 3 commits intodirien:mainfrom
DavidHoenisch:fix/working-example-with-env-vars

Conversation

@DavidHoenisch
Copy link
Copy Markdown
Contributor

This change does a few things.

  1. to make it so that env vars do not have to be and can take full advantage of the pulumi.yaml file, a config block was added
cfg := config.New(ctx, "fly")
flyToken := cfg.RequireSecret("fly_api_token")

then, we create the provider explicitly and pass in the fly token from the config

flyProvider, err := fly.NewProvider(ctx, "fly-provider", &fly.ProviderArgs{
	FlyApiToken: flyToken,
})
if err != nil {
	return err
}
  1. Best that I could find, this pulumi provider is using v1 of the machines API. This mean that dns records are not automatically setup for the fly and and while it deploys fine, it is essentially "orphaned". To fix this, we can inject the following vars into the machine
Env: pulumi.StringMap{
    "FLY_PROCESS_GROUP": pulumi.String("app"),
    "PRIMARY_REGION":    pulumi.String(region),
},

This will ensure that once the app is deploy it will automatically get a *.fly.dev domain issued to it.

A note on this. I believe all of this would be handled automatically in v2 of the fly api. However, it also appears that this repo is bridging from a TF provider that is no longer maintained. There are some forks of the OG fly tf provider but all of them are largely not being updated much either. As such, a little bit of extra config is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant