You can use BuildFlow to manage your cloud resources. This removes the need to have a separate configuration management tool such as Terraform, or from managing your resources manually in the cloud console. All the code for this guide can be found on GitHub.

To do this you simply mark your primitives as managed by your flow and BuildFlow will take care of the rest.

To see a full working project example with a UI included see our Image Classification example.


Initialize Flow

First we create a new BuildFlow Flow. This will be the main entry point to our application.

app = Flow()

Define our Primitives

Now we define the primitives we would like to be managed. In our example we define an S3Bucket and a GCPPubSubTopic.

bucket = S3Bucket(bucket_name="my-bucket", aws_region="us-east-1")
topic = GCPPubSubTopic(topic_name="my-topic", project_id=os.environ["GCP_PROJECT_ID"])

Mark our Primitives as Managed

Finally we mark our primitives as managed by our flow. This tells our flow that is responsible for creating, updating, and destroying these resources.

app.manage(bucket, topic)

Preview our Changes

Now we can use the VS Code extension or the BuildFlow CLI to preview our changes:

buildflow preview

This will output the changes that will be made to our resources. In our case we will see that a new S3 bucket and GCP PubSub topic will be created.

Primitives to create:
├── S3Bucket
│   └── s3://my-bucket
└── GCPPubSubTopic
    └── my-project/my-topic

Apply our Changes

If we’re happy with the preview we can now use the VS Code extension or BuildFlow CLI to apply our changes.

buildflow apply

This will again output the preview and ask you to confirm.

You can use FlowOptions to disable the confirmation requirement.

After this step you should be able to view your resources in the cloud console.


Update our Resources

If we ever change our resources, for example updating a configuration option on our bucket or topic, we can run buildflow apply again to have the resource updated.


Destroy your Resources

If you ever want to delete all of the resources for your project, you can simply run buildflow destroy. Similar to apply this will preview the changes and ask you to confirm.

If you no longer need a resource for your project you can simply remove it from being managed and when you run buildflow apply it will be deleted. For example if we no longer needed our S3 bucket we could remove it from our call to app.manage:



buildflow apply

And you will see that the S3 bucket is deleted.