LifecycleAlpha

Create, update and destroy an infrastructure

Now that you've downloaded your infrastructure code and created your environments you may want to create the ressources on your AWS account(s).

To do this, Scaffold mimics the plan, apply and destroy Terraform commands to create, update and destroy your infrastructure.

Creating and updating an infrastructure

If you are familiar with Terraform you may already know that you can create and update an infrastructure using the apply command.

The plan command is used to display all the actions (creation, update, deletion) that will be made on your infrastructure resources without doing anything.

Create your first infrastructure now by running the apply command in your infrastructure directory:

$ scaffold apply

›   Error: Missing 1 required arg:
›   environment
›   See more help with --help

As you can see, it doesn't work because Scaffold doesn't have the concept of "default" or "current" environment that you've been accustomed to while using other libraries.

In Scaffold, all the commands that affect an infrastructure must be appended with the name of an environment.

For example, to create the infrastructure of your dev environment, you need to run the apply dev command:

$ scaffold apply dev

Synthesizing... done

...

Plan: 14 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: 

Type "yes" to create this infrastructure in your dev environment:

$ scaffold apply dev

Synthesizing... done

...

Plan: 14 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_acm_certificate.scaffoldawsstaticwebsite_ssl_websitecertificate_1D721F96: Creation complete after 7s [id=arn:aws:acm:us-east-1:645401141346:certificate/8abbf749-a958-4193-b1e2-8c9fd3bfe59d]
aws_s3_bucket.scaffoldawsstaticwebsite_continuousdeployment_pipelinebucket_DF38B2AB: Creation complete after 10s [id=scaffold-5f5a1e541759213213677205-codepipeline-bucket]
aws_s3_bucket.scaffoldawsstaticwebsite_bucket_websitebucket_ED23B4C6: Still creating... [10s elapsed]
aws_s3_bucket.scaffoldawsstaticwebsite_bucket_websitebucket_ED23B4C6: Creation complete after 16s [id=scaffold-5f5a1e541759213213677205-website-bucket]

...

Apply complete! Resources: 14 added, 0 changed, 0 destroyed.
Releasing state lock. This may take a few moments...

Outputs: ...

Thats it! Your infrastructure is created.

Updating an infrastructure

Updating an infrastructure follows the same process:

  1. Update your infrastructure code
  2. Run the apply {environment} command
  3. Review the modifications and approve by typing "yes"

Destroying an infrastructure

As you might have already guessed, destroying an infrastructure means calling the destroy command:

$ scaffold destroy dev

Another environment

If you remember correctly from the environments section, each environment has their own state and configuration.

As a result, if you run the scaffold apply prod command now, you will be asked to create the same resources than for the dev environment but with a different configuration:

$ scaffold apply prod

Synthesizing... done

...

Plan: 14 to add, 0 to change, 0 to destroy.