HiveBrain v1.2.0
Get Started
← Back to all entries
snippetterraformMinor

How do I export my state from my stack while using Spacelift?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
whilestackspaceliftstateexporthowusingfrom

Problem

I am currently using Spacelift and on my stack, the state is managed by Spacelift.

I am happy with this but I want to export the state to an Amazon S3 bucket, is there any way to do this?

Solution

The Terraform state file can be pulled and then exported using a Task.

For example, to export the state to an Amazon S3 bucket, you would run the following command as a Task:

terraform state pull > state.json && aws s3 cp state.json s3://

For that example to work, the stack needs to have write access to the AWS S3 bucket, possibly via an AWS Integration.

You could also set up a hook to constantly run this command at a specific part of your run.

Context

StackExchange DevOps Q#18762, answer score: 2

Revisions (0)

No revisions yet.