This page explains the basics of using AsCode to define your infrastructure in Terraform. It assumes that you have already installed Ascode.
> ascode --help
+
diff --git a/docs/getting-started/index.html b/docs/getting-started/index.html index 06147d9..da7ba59 100644 --- a/docs/getting-started/index.html +++ b/docs/getting-started/index.html @@ -1,5 +1,5 @@
This page explains the basics of using AsCode to define your infrastructure in Terraform. It assumes that you have already installed Ascode.
> ascode --help
+
This page explains the basics of using AsCode to define your infrastructure in Terraform. It assumes that you have already installed AsCode.
> ascode --help
Usage:
ascode [OPTIONS] <repl | run | version>
@@ -23,7 +23,7 @@ resource "aws_instance" "web
provider = aws.id_01E4JV722PS2WPKK7WQ2NMZY6D
instance_type = "t2.micro"
}
-
run
commandThe run
command executes a valid Starlack program. Using the --print-hcl
and --to-hcl
, an HCL encoded version of the tf
object will be printed or saved to a given file, respectively.
This is the first step to deploy any infrastructure d defined with AsCode, using run
and generating a valid .tf
file, we can use the standard Terraform tooling to deploy our infrastructure using terraform init
, terraform plan
and terraform apply
.
To learn about writing Starlark programs, please refer to the Language definition and the API Reference sections of this documentation.
The goal of the example is create, in DigitalOcean, one s-1vcpu-1gb
instance called web
in the nyc2
region:
For running this example, you need
terraform
correctly installed on your system.
> mkdir example; cd example
+
run
commandThe run
command executes a valid Starlack program. Using the --print-hcl
and --to-hcl
, an HCL encoded version of the tf
object will be printed or saved to a given file, respectively.
This is the first step to deploy any infrastructure defined with AsCode, using run
and generating a valid .tf
file, we can use the standard Terraform tooling to deploy our infrastructure using terraform init
, terraform plan
and terraform apply
.
To learn about writing Starlark programs, please refer to the Language definition and the API Reference sections of this documentation.
The goal of the example is to create, in DigitalOcean, one s-1vcpu-1gb
instance called web
in the nyc2
region:
To run this example, you need
terraform
correctly installed on your system.
> mkdir example; cd example
> echo 'do = tf.provider("digitalocean")' > main.star
> echo 'web = do.resource.droplet("web", name="web", size="s-1vcpu-1gb")' >> main.star
> echo 'web.region = "nyc2"' >> main.star
@@ -44,7 +44,7 @@ resource "digitalocean_droplet"
}
-
And now as it’s common in terraform we can run init
, plan
or/and apply
> terraform init
+
And now as it’s usual in terraform we can run init
, plan
or/and apply
> terraform init
...
> terraform plan
Terraform will perform the following actions:
diff --git a/docs/github-action/index.html b/docs/github-action/index.html
index 54968be..fd53546 100644
--- a/docs/github-action/index.html
+++ b/docs/github-action/index.html
@@ -1,5 +1,5 @@
GitHub Action - AsCode - Terraform Alternative Syntax GitHub Action
AsCode Github Action allows to execute AsCode run
command in response to a GitHub event such as updating a pull request or pushing a new commit on a specific branch.
This used in combination with the Terraform GitHub Actions allows to execute the different terraform commands init
, plan
and apply
inside of a GitHub Workflow.
Parameters
Parameter Mandatory/Optional Description file Mandatory Starlark file to execute. Default value: main.star
hcl Mandatory HCL output file. Default value: generated.tf
Recommended Workflow
name: 'Terraform & AsCode'
+
GitHub Action
AsCode Github Action allows to execute AsCode run
command in response to a GitHub event such as updating a pull request or pushing a new commit to a specific branch.
This used in combination with the Terraform GitHub Actions allows to execute the different terraform commands init
, plan
and apply
inside of a GitHub Workflow.
Parameters
Parameter Mandatory/Optional Description file Mandatory Starlark file to execute. Default value: main.star
hcl Mandatory HCL output file. Default value: generated.tf
Recommended Workflow
name: 'Terraform & AsCode'
on:
push:
branches:
@@ -12,14 +12,14 @@
runs-on: ubuntu-latest
env:
TF_VERSION: latest
- TF_WORKING_DIR: .
+ TF_WORKING_DIR: .
steps:
- name: 'Checkout'
uses: actions/checkout@master
- name: 'AsCode Run'
uses: mcuadros/ascode@gh-action
-
+
- name: 'Terraform Init'
uses: hashicorp/terraform-github-actions@master
with:
diff --git a/docs/index.html b/docs/index.html
index 0627b7a..bbcb857 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1,2 +1,2 @@
Documentation - AsCode - Terraform Alternative Syntax OverviewDocumentation
AsCode - Terraform Alternative Syntax
AsCode is a tool to define infrastructure as code using the Starlark language on top of Terraform. It allows to describe your infrastructure using an expressive language in Terraform without writing a single line of HCL, meanwhile, you have the complete ecosystem of providers
Why?
Terraform is a great tool, with support for almost everything you can imagine, making it the industry leader. Terraform is based on HCL, a JSON-alike declarative language, with minimal control flow functionality. IMHO, to unleash the power of the IaC, a powerful, expressive language should be used, where basic elements like loops or functions are first-class citizens.
What is Starlark?
Starlark is a dialect of Python intended for use as a configuration language. A Starlark interpreter is typically embedded within a larger application, and this application may define additional domain-specific functions and data types beyond those provided by the core language. For example, Starlark is embedded within (and was originally developed for) the Bazel build tool, and Bazel’s build language is based on Starlark.
OverviewDocumentation
AsCode - Terraform Alternative Syntax
AsCode is a tool to define infrastructure as code using the Starlark language on top of Terraform. It allows to describe your infrastructure using an expressive language in Terraform without writing a single line of HCL, meanwhile, you have the complete ecosystem of providers
Why?
Terraform is a great tool, with support for almost everything you can imagine, making it the industry leader. Terraform is based on HCL, a JSON-alike declarative language, with minimal control flow functionality. IMHO, to unleash the power of the IaC, a powerful, expressive language should be used, where basic elements like loops or functions are first-class citizens.
What is Starlark?
Starlark is a dialect of Python intended to be used as a configuration language. A Starlark interpreter is typically embedded within a larger application, and this application may define additional domain-specific functions and data types beyond those provided by the core language. For example, Starlark is embedded within (and was originally developed for) the Bazel build tool, and Bazel’s build language is based on Starlark.
macOS (Darwin)
wget https://github.com/mcuadros/ascode/releases/download/dev/ascode-dev-darwin-amd64.tar.gz
tar -xvzf ascode-dev-darwin-amd64.tar.gz
mv ascode /usr/local/bin/
-
Source
Prerequisite Tools
Clone from GitHub
AsCode uses the Go Modules, so e easiest way to get started is to clone AsCode in a directory outside of the $GOPATH
, as in the following example:
git clone https://github.com/mcuadros/ascode.git $HOME/ascode-src
+
Source
Prerequisite Tools
Clone from GitHub
AsCode uses the Go Modules, so the easiest way to get started is to clone AsCode in a directory outside of the $GOPATH
, as in the following example:
git clone https://github.com/mcuadros/ascode.git $HOME/ascode-src
cd $HOME/ascode-src
-go install ./...
+go install ./...