terratest & jenkins ci/cd with terraform, modern ... · terraform init $ cd tf $ terraform init...

49
Modern Provisioning and CI/CD with Terraform, Terratest & Jenkins Duncan Hutty

Upload: others

Post on 22-May-2020

70 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Modern Provisioning andCICD with Terraform

Terratest amp JenkinsDuncan Hutty

Overview

1 Introduction Context Philosophy

2 Provisioning Exercises

1 MVP

2 Testing

3 CICD

4 Refactoring

3 Coping with complexity amp scale

httpgitlabcomdhuttymodern-provisioning_code

IntroductionContext

Philosophy

ContextInfrastructure

Conguration [Management]

Orchestration

Provisioning

CICD

Pipelines

Philosophy

Everything As CodeUse Code for Everything

Test

Review

Lifecycle

Engineer All The Code

Infrastructure As CodeTreating the tooling that provisions and manages your infrastructure with the same respect as other

code

Engineering ServicesEngineering Engineering

Benets of As CodeEasier to

Consistently regenerate

Test

Review

Grok

Audit

Iteratively improve

Reuse compose and hide complexity

TechVCS git+ github

Scheduler Jenkins

PaaS IaaS AWS

Provisioning making somewhere to deploy to Terraform

Testing Jenkinsles simple scripts Terratest

And with all that said letrsquos get on to making things happen showing some code

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 2: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Overview

1 Introduction Context Philosophy

2 Provisioning Exercises

1 MVP

2 Testing

3 CICD

4 Refactoring

3 Coping with complexity amp scale

httpgitlabcomdhuttymodern-provisioning_code

IntroductionContext

Philosophy

ContextInfrastructure

Conguration [Management]

Orchestration

Provisioning

CICD

Pipelines

Philosophy

Everything As CodeUse Code for Everything

Test

Review

Lifecycle

Engineer All The Code

Infrastructure As CodeTreating the tooling that provisions and manages your infrastructure with the same respect as other

code

Engineering ServicesEngineering Engineering

Benets of As CodeEasier to

Consistently regenerate

Test

Review

Grok

Audit

Iteratively improve

Reuse compose and hide complexity

TechVCS git+ github

Scheduler Jenkins

PaaS IaaS AWS

Provisioning making somewhere to deploy to Terraform

Testing Jenkinsles simple scripts Terratest

And with all that said letrsquos get on to making things happen showing some code

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 3: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

IntroductionContext

Philosophy

ContextInfrastructure

Conguration [Management]

Orchestration

Provisioning

CICD

Pipelines

Philosophy

Everything As CodeUse Code for Everything

Test

Review

Lifecycle

Engineer All The Code

Infrastructure As CodeTreating the tooling that provisions and manages your infrastructure with the same respect as other

code

Engineering ServicesEngineering Engineering

Benets of As CodeEasier to

Consistently regenerate

Test

Review

Grok

Audit

Iteratively improve

Reuse compose and hide complexity

TechVCS git+ github

Scheduler Jenkins

PaaS IaaS AWS

Provisioning making somewhere to deploy to Terraform

Testing Jenkinsles simple scripts Terratest

And with all that said letrsquos get on to making things happen showing some code

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 4: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

ContextInfrastructure

Conguration [Management]

Orchestration

Provisioning

CICD

Pipelines

Philosophy

Everything As CodeUse Code for Everything

Test

Review

Lifecycle

Engineer All The Code

Infrastructure As CodeTreating the tooling that provisions and manages your infrastructure with the same respect as other

code

Engineering ServicesEngineering Engineering

Benets of As CodeEasier to

Consistently regenerate

Test

Review

Grok

Audit

Iteratively improve

Reuse compose and hide complexity

TechVCS git+ github

Scheduler Jenkins

PaaS IaaS AWS

Provisioning making somewhere to deploy to Terraform

Testing Jenkinsles simple scripts Terratest

And with all that said letrsquos get on to making things happen showing some code

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 5: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Philosophy

Everything As CodeUse Code for Everything

Test

Review

Lifecycle

Engineer All The Code

Infrastructure As CodeTreating the tooling that provisions and manages your infrastructure with the same respect as other

code

Engineering ServicesEngineering Engineering

Benets of As CodeEasier to

Consistently regenerate

Test

Review

Grok

Audit

Iteratively improve

Reuse compose and hide complexity

TechVCS git+ github

Scheduler Jenkins

PaaS IaaS AWS

Provisioning making somewhere to deploy to Terraform

Testing Jenkinsles simple scripts Terratest

And with all that said letrsquos get on to making things happen showing some code

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 6: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Everything As CodeUse Code for Everything

Test

Review

Lifecycle

Engineer All The Code

Infrastructure As CodeTreating the tooling that provisions and manages your infrastructure with the same respect as other

code

Engineering ServicesEngineering Engineering

Benets of As CodeEasier to

Consistently regenerate

Test

Review

Grok

Audit

Iteratively improve

Reuse compose and hide complexity

TechVCS git+ github

Scheduler Jenkins

PaaS IaaS AWS

Provisioning making somewhere to deploy to Terraform

Testing Jenkinsles simple scripts Terratest

And with all that said letrsquos get on to making things happen showing some code

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 7: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Infrastructure As CodeTreating the tooling that provisions and manages your infrastructure with the same respect as other

code

Engineering ServicesEngineering Engineering

Benets of As CodeEasier to

Consistently regenerate

Test

Review

Grok

Audit

Iteratively improve

Reuse compose and hide complexity

TechVCS git+ github

Scheduler Jenkins

PaaS IaaS AWS

Provisioning making somewhere to deploy to Terraform

Testing Jenkinsles simple scripts Terratest

And with all that said letrsquos get on to making things happen showing some code

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 8: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Engineering ServicesEngineering Engineering

Benets of As CodeEasier to

Consistently regenerate

Test

Review

Grok

Audit

Iteratively improve

Reuse compose and hide complexity

TechVCS git+ github

Scheduler Jenkins

PaaS IaaS AWS

Provisioning making somewhere to deploy to Terraform

Testing Jenkinsles simple scripts Terratest

And with all that said letrsquos get on to making things happen showing some code

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 9: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Benets of As CodeEasier to

Consistently regenerate

Test

Review

Grok

Audit

Iteratively improve

Reuse compose and hide complexity

TechVCS git+ github

Scheduler Jenkins

PaaS IaaS AWS

Provisioning making somewhere to deploy to Terraform

Testing Jenkinsles simple scripts Terratest

And with all that said letrsquos get on to making things happen showing some code

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 10: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

TechVCS git+ github

Scheduler Jenkins

PaaS IaaS AWS

Provisioning making somewhere to deploy to Terraform

Testing Jenkinsles simple scripts Terratest

And with all that said letrsquos get on to making things happen showing some code

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 11: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Provisioning Exercises1 MVP

2 Terratest

3 Containerization

4 CICD

5 Refactoring

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 12: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Setup

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 13: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Clone the Repository$ git clone httpsgitlabcomdhuttymodern-provisioning_code

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 14: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Terraform installationHashicorp provides for Terraform

install the binary as terraform-ltversiongt

Install

installation instructions

ln -s ~binterraform-ltversiongt ~binterraform alias tf=terraform

jq

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 15: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

TerratestInstall terratest

for M in $(cat terratest_modulestxt) do go get githubcomgruntwork-ioterratestmodules$M done for P in $(cat go_packagestxt) do go get $P done

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 16: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

AWS

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 17: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Install CLI tooling$ virtualenv -p python3 --no-site-packages venv $ source venvbinactivate $ pip install awscli

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 18: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

AWS provider for TerraformTerraform ships a provider for AWS all you need is to congure

provider aws region = us-east-1 the only required argument version = ~gt 136

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 19: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

terraform init$ cd tf $ terraform init Initializing provider plugins Terraform has been successfully initialized You may now begin working with Terraform Try running terraform plan to see any changes that are required for your infrastructure All Terraform commands should now work If you ever set or change modules or backend configuration for Terraform rerun this command to reinitialize your working directory If you forget other commands will detect it and remind you to do so if necessary

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 20: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

AWS accountCreate a API key to interact with AWS itself

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 21: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Environment variables$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-east-1

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 22: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Conguration les~awsconfig

~awscredentials

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 23: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Proofaws --output table ec2 describe-regions ---------------------------------------------------------- | DescribeRegions | +--------------------------------------------------------+ || Regions || |+-----------------------------------+------------------+| || Endpoint | RegionName || |+-----------------------------------+------------------+| || ec2ap-south-1amazonawscom | ap-south-1 || || ec2eu-west-3amazonawscom | eu-west-3 || || ec2eu-west-2amazonawscom | eu-west-2 || || ec2eu-west-1amazonawscom | eu-west-1 || || ec2ap-northeast-2amazonawscom | ap-northeast-2 || || ec2ap-northeast-1amazonawscom | ap-northeast-1 || || ec2sa-east-1amazonawscom | sa-east-1 || || ec2 ca-central-1 amazonaws com | ca-central-1 ||

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 24: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

MVPan instance

a security group

a key_pair so it can be reached

lots of that can be ignored if you have a Default VPCnetworking-fu

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 25: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Provider Conguration

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 26: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Variables

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 27: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Outputs

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 28: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Proofsource localshexample tf plan ssh ec2-user$PUBLIC_IP echo $(hostname --fqdn)

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 29: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Provisioning

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 30: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Congure with user_dataPass a shell script and it will be run upon launch

Proof curl -v httpltpublic_ip_of_new_instancegt8080

EC2 Docs on user_data

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 31: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Conguring with Ansibleresource null_resource install-python provisioner remote-exec inline = [ sudo yum install -y python-virtualenv ] connection type = ssh private_key = $file(varssh_private_key_path) user = $varssh_user host = $aws_instancemvppublic_ip

provisioner local-exec command = ansible-playbook -vD -i ansiblehosts playbookyml

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 32: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Templated output for Ansible Inventory

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 33: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Proofcurl -v -F= ansible_host print $2 ansiblehosts)8080

curl -v -F= ansible_host print $2 ansiblehosts)8081

http$(awk

http$(awk

ansible -i ansiblehosts -m shell -a hostname --fqdn ampamp uptime all ansible-playbook -vD -i ansiblehosts playbookyml

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 34: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

TerratestGo testing write les _testgo run go test

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 35: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Containers

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 36: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Containerize pythonhttp

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 37: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Containerize Jenkins

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 38: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

CICD

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 39: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Refactoring

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 40: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Terraform ModulesModules are encapsulated Terraform conguration that are used to

better organize TF code

make TF code more easily resuable

httpswwwterraformiodocsmodulescreatehtmlstandard-module-structure

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 41: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Terraform State

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 42: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

The End

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 43: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Repositorieshttpgitlabcomdhuttymodern-provisioning_code

httpgitlabcomdhuttypythonhttp

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 44: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Extrashttpsregistryterraformio

httpsgithubcomsegmentioterraform-docs

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 45: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Further WorkPort to OCI Azure GCP

Add support for other infrastructure resource types including non-IaaS

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 46: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

ColophonThis repository contains both the class (presentation) and the demonstration code

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 47: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

The Presentationwritten in

uses and for slideshow functionality

needs to run a local server for speaker notes

asciidoc

asciidoctor revealjs

nodejsnpm

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 48: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

Software SetupInstall I used rvm and

Clone this repository From the root of this repo clone revealjs repository with

Point revealjs app at this presentation with

Install all the node-fu and start the webserver with

asciidoctor-revealjs $ rm -f Gemfilelock bundle config --local githubhttps true bundle --path=bundlegems --binstubs=bundlebin

git clone httpsgithubcomhakimelrevealjsgit

ln -sf indexhtml indexhtml

npm install ampamp npm start -- --port=5000

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf

Page 49: Terratest & Jenkins CI/CD with Terraform, Modern ... · terraform init $ cd tf $ terraform init Initializing provider plugins... Terraform has been successfully initialized! You may

UsageFrom the top repo generate the presentation with

Visit

Exporting Slides to PDF

$ bundle exec asciidoctor-revealjs -a revealjsdir= presentationindexadoc

httplocalhost5000

$ docker run --rm -v `pwd`homeuser astefanuttidecktape homeuserindexhtml homeuserslidespdf