0

I'm building a project with Azure Static Web Apps and the Python CDK for Terraform but I'm unsure how do I get the built app / static files onto the Cloud, I'd like to have my process streamlined so that everything gets done when running cdktf deploy

Using the Static Web Apps CLI this can be done, but it's not a Python library

swa deploy ./prod_static --env=production --deployment-token token

And the Terraform resource doesn't mention any deployment files as far as I can see

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/static_web_app

Is there some sort of Static Web Apps SDK?

6
  • 1
    Is there any issue when deploying with swa deploy? Do you need to deploy Azure Static Web Apps with Terraform or Python? Either of those is fine Commented Dec 5, 2024 at 12:50
  • Well yes, swa is a cli utility, I'm looking for something to programmatically deploy it Commented Dec 5, 2024 at 12:58
  • Are you looking only for a terraform approach. @Filip Commented Dec 6, 2024 at 9:30
  • 1
    Ideally Terraform or Python but alternatives are welcome @Jahnavi Commented Dec 6, 2024 at 17:40
  • 1
    Yes I am @Jahnavi but I've accepted the workaround of doing this later in the pipeline and not integrating it with cdktf deploy... I'll post my solution Commented Dec 10, 2024 at 23:54

1 Answer 1

0

A workaround is to output the api_key (deployment token) from Terraform

TerraformOutput(
    self,
    'swa',
    sensitive=True,
    value=app_web.api_key
)

And use it later in the pipeline, stripped version of a script for my use case

SWA_CLI_DEPLOYMENT_TOKEN=$(terraform -chdir=cdktf.out/stacks/urlshortener-stack output -raw swa) \
npx --yes @azure/static-web-apps-cli deploy ./prod_static --env=production
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.