Skip to main content

Aws Getting Started

This tutorial explains the code generation from a live infrastructure. Instead of manually coding the infrastructure, GruCloud automatically creates the infrastructure as code.

Workflow#

gc-new-aws

AWS Requirements#

  • AWS Account
  • AWS CLI
  • Access and Secret Key

AWS Account#

Ensure access to the Amazon Console and create an account if necessary.

AWS CLI#

Ensure the AWS CLI is installed and configured:

aws --version

If not, visit https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html

Access and Secret Key#

Visit the security credentials

  • Click on Access key (access key ID and secret access key).
  • Click on the button Create New Access Key.

Write down the AWSAccessKeyId and AWSSecretKey

In a further episode, the access and secret key will be obtained from a dedicated IAM user with the correct role and policy.

Getting the GruCloud CLI#

This chart describes the way to install gc, the GruCloud CLI:

gc-cli-install

GruCloud is written in Javascript running on Node.js. Check if node is present on your system

node --version

The version must be greater than 14

Install the GrucCloud command-line utility gc with npm

npm i -g @grucloud/core

Check the current version of gc:

gc --version

Create a new project#

The new command guides you on how to create and configure a new project.

gc-new-aws

Below is the screencast of gc new:

The boilerplate project is now created and configured.

List the live resources#

Visualize your current infrastructure with the list command:

gc list --graph

diagram-live.svg

Generate the code#

gc gencode

The live resources will be fetched and the code generated in resource.js. A diff between the current file and the new one is displayed.

Target Graph#

The graph command creates a dependency graph of the target resources:

gc graph

Resource mind map#

Given the target resources defined in resources.js, let's generate a mindmap of the target resources by group and type.

gc tree

diagram-live.svg

Update#

To update the infrastructure, either use the AWS console and run gc gencode, or modify directly the file resource.js. Once done, use the apply command to update the infrastructure:

gc apply

Destroy#

Resources can be destroyed in the right order with the destroy command:

gc destroy