fabiochiu/medium-articles huggingface dataset:
One River Asset Management Announces $600 Million Purchase of Bitcoins
By: Bitxmi Pte Ltd
Tags: Bitxmi, Bitcoin, Investment, Btc, Cryptocurrency Investment

Kataryna Habeliia December 17, 2020

www.bitxmi.com

Table of Contents

Hedge Fund One River Asset Management Announces $600 Million Purchase of Bitcoins

Eric Peter, head of the hedge fund One River Asset Management, said that by early 2021 the company plans to increase the volume of its cryptocurrency assets to $ 1 billion.

Hedge fund together with the co-founder of Brevan Howard Asset Management, billionaire Alan Howard, acquired more than $ 600 million of cryptocurrency, writes Bloomberg. The ORDAM Fund, launched in October specifically for investments in cryptocurrencies, plans to increase the volume of assets in bitcoins and ethers to $ 1 billion by the beginning of 2021.

One River Asset Management started accumulating in November

The company bought the cryptocurrency in November, without attracting everyone’s attention, so as not to provoke a sharp rise in the bitcoin rate. The coins were bought at a price of less than $ 16 thousand for one bitcoin. On December 17, the cryptocurrency rate reached $ 23.8 thousand, at the moment Bitcoin is traded at a level of $ 23500 thousand on the BitXmi cryptocurrency exchange.

Northern Trust will act as the administrator of the One River Digital Asset Management funds, the Coinbase crypto exchange from the USA will deal with the execution of transactions and act as a custodian partner. The head of the hedge fund, Eric Peter, emphasized that the cryptocurrency market has higher risks than gold, but it also offers higher returns.

Read new crypto forecasts and current crypto news every day at https://news.bitxmi.com/

Join Bitxmi Exchange

Disclaimer: Bitxmi News is a news portal and does not provide any financial advice. Bitxmi’s role is to inform the cryptocurrency and blockchain community about what’s going on in this space. Please do your own due diligence before making any investment. Bitxmi News won’t be responsible for any loss of funds.
Kickback & Passive Income. A Detailed Description
Tags: Bitcoin, Cryptocurrency, Cryptotrading, Btc, Investments Opportunity

We all know what cashbacks are. This is a cool one-time story, but this is not for a lifetime.

Kickback and KICKS are a different thing.

If you make a purchase with cashbacks, you receive a portion of the percentage back. One day, you will save enough money to receive a significant discount. But all your financial privileges with cashbacks will be limited with your own purchases. The only rule for you to get any bonus will be to buy something yourself.

How does it work with kickbacks? They do not depend on your personal expenses at all. You can proceed to buy only once. Afterwards, you will be rewarded for purchases made by your friends. You may not have money but you will be motivated to share Sessia with anyone who will become your source of income.

So why do you need cashbacks if their lives are so short? There is no answer.

That is why KICKS are worthy. An asset backed with a real idea, tool, or business is bound to rock. The idea behind KICKS is great for many people, both random users and businessmen.

Kickback is the viral cashback. Cashback 2.0. The tool of passive income and eternal promotion that will be working forever.

Follow us on Medium, Reddit, or Instagram to stay updated about the news!
Terraform으로 AWS ECS Fargate + Route53 웹 서비스 배포하기
By: Key Kim
Tags: AWS, Elastic Container Service, Route 53, Terraform

KimKiHyuk/terraform-boilerplate

You can't perform that action at this time. You signed in with another tab or window. You signed out in another tab or…
Wrap your terraform code with terragrunt
By: Raja Gopal
Tags: Wrapper, Terragrunt, Grunt Work, Terraform

Source: simpleprogrammer.com

Hello All !!! Welcome to my new story on terragrunt.

We all know what is a wrapper. In general, a wrapper is something which covers the underlying material. There are many examples we see in our daily life like pan masala wrapped with a tobacco leaf, potato masala inside a Roti and many others. Similarly, in IT there are called wrappers, which are functions written to execute one or more other subroutines.

In the DevOps world, the most commonly used tool for infrastructure is terraform, where you write the infrastructure as code and the language it uses is HCL. Terraform has many commands of which the commonly used are “plan”, “apply” and “destroy”. Every time when we plan an orchestration of terraform files, we need to take care of provider information, variable files and the static analysis before anything can be applied. To achieve this, we normally use any of the popular scripting tools like bash, PowerShell, Python, etc. This brings in another challenge to study the scripting language which may put you down.

A simple solution is offered by Gruntwork.io with a software called terragrunt, where you write your wrapper in HCL format which puts a smile on your face :)

Terragrunt

Imagine you have a repository with terraform files that will build infrastructure for various environments like Dev, QA, Stage and Prod. How are you going to manage the code? Are you going to write a repo/branch for each env? That make your work hectic. Terragrunt offers a solution where you can write terragrunt files for each env folder with different inputs

Think another scenario.

You were to execute tfsec or any other static code analysis before you execute terraform plan or apply, how will you enforce it. Auto init terraform Auto retry in case of a network failure Debug the terraform commands Avoid writing provider information into all terraform code

The above listed are a few of the solutions it actually provides. For more information, read the documentation at https://terragrunt.gruntwork.io/docs/features/debugging/#debugging

To explain the above solutions, I will provide you an example terragrunt configuration.

generate "provider" { path = "provider.tf" if_exists = "overwrite_terragrunt" contents = <<EOF provider "azurerm" { client_id = var.client_id client_secret = var.client_secret subscription_id = var.subscription_id tenant_id = var.tenant_id features {} } EOF } terraform { extra_arguments "common_vars" { commands = get_terraform_commands_that_need_vars() arguments = [ "-var-file=variables.tfvars" ] } before_hook "before_hook_1" { commands = ["apply", "plan"] execute = ["tfsec"] } }

The above script can run tfsec before any of the commands like plan or apply, it picks the vars file and provider file for any environment it is going to be deployed.

Let’s see how it executes when deployed

This also helps when creating a CI/CD with tools like jenkins pipeline

Thanks for reading this article. We will bring up more such valuable stories for you.
Terraform Backend Config interpolation using Jenkinsfile
By: Ravish Kumar
Tags: Jenkins, Vmware Vsphere, Google Cloud Platform, Terraform Provider, Terraform

Terraform is a popular tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

Here I will talk about an in-house solution based on VMware vSphere. I will try to keep it short and crisp.

Problem Statement:

While creating resources in vSphere using Terraform (v0.12.x onwards) “VMware vSphere Provider”, needs to save Terraform State File in Google Cloud Storage (GCS).

Resource needs to created in OnPrem and the terraform state file needs to be stored in GCS. Let’s see the solution for this requirement.

References to solve the problem:

As per terraform’s default execution steps, any configured backend must be initialized before usage. This is done by running “terraform init”. GCS backend type supports “credentials” as one of the configuration options.

Will use both choices to illustrate an example for this blog.

Solution:

Terraform suggests that certain arguments such as secrets/credentials can be omitted in the backend configuration; making it a Partial Configuration.

With partial backend configuration, there are two methods to supply the remaining arguments.

File Method (default) — $terraform init -backend-config=backend.tfvars Command-line key/value pair — Key-Value pairs can be specified with "init" command line.

Combining both methods of partial configuration will help us to solve the problem. Here goes code snippet —

$ cat backend.tf

terraform {

backend "gcs" {

credentials = var.gcp_sandbox

}

} $ cat backend.tfvars

bucket = "terraform-demo"

prefix = "terraform/demo" $ terraform init -backend-config "credentials=$TF_VAR_GCP_SANDBOX" -backend-config=backend.tfvars

Now will encapsulate everything in JenkinsFile to complete the process. Add GCS service account JSON as Jenkins credential “SANDBOX_CRED” and it will be interpolated into Terraform.

$ cat Jenkinsfile

pipeline {

agent none

stages {

stage('Terraform Plan') {

agent { label 'terraform' }

steps {

script {

withCredentials([file(credentialsId: 'SANDBOX_CRED', variable: 'TF_VAR_GCP_SANDBOX')]) {

sh '''

terraform init -backend-config

"credentials=$TF_VAR_GCP_SANDBOX" -backend-config=backend.tfvars

terraform plan --var-file=sandbox.tfvars

'''

}

}

}

}

}

}

In this way, any resource can be created in OnPrem ( using VMware vSphere Provider ), and terraform state file can be stored in GCS.

That’s all !!!
AWS SQS hidden polling costs
By: Jose Antonio Gonzalez
Tags: Sqs, Lambda, S3, AWS, Terraform

When building event-driven applications it’s common to process objects that are uploaded to an S3 bucket. There are several ways to listen to S3 events using S3 notifications. You could directly call a lambda function after every upload or send the notification an to SNS topic/SQS queue as an intermediary between the two.

For a high-performance and scalable solution that handles errors, SQS is the best option.

Lambda has a limit of 1000 concurrent invocations per second.

SNS doesn’t guarantee that every notification will be delivered only once.

If the delivery throws an error, SQS lets you retry delivery to the consumer (e.g. Lambda) depending on your redrive policy. If the retries are exhausted then you can process errors separately with a dead-letter queue (DLQ).

The setup is straightforward.

AWS gives you one million messages for free every month. After that it’s only $0.40 per million messages, so the cost is low.

The problem comes with Lambda continuously polling the queue listening for new messages inside it. This polling produces empty messages if there are none. These messages count against AWS free tier requests. Lambda functions will have has five instances polling every 20 seconds.
Provisioning Spot Instance Nodegroup into EKS via Terraform
By: Nicholas Lu
Tags: Kubernetes, Eks, Spotinstance, AWS, Terraform

First: Create cluster

To create a cluster, you will need to start with the terraform, it should look like this.

First we are going to build the vpc using terraform, you can skip this method if you are using default vpc but I prefer to make it from ground up, therefore I will create a new vpc with three public subnet and three private subnet together with NAT gateway(you may want to comment out it if you are planning to do a basic setup and I recommend you to try the basic setup)

With the vpc created, you can now proceed with the eks cluster creation. The code will look like this, you will need to fill the subnet, vpc ids created earlier and I separate this from vpc due the the fact vpc is there to stay even the cluster is destroyed and you can reuse it back.

Run the code and you should get a cluster with no nodegroup inside, keep that in mind I have left some of the part to be filled later(both variable aws_user and aws_nodegroup will need to be updated later)as we create our nodegroup.

Second: Create nodegroup via terraform

We have already create the cluster and vpc and they should be up and running, but now we dont have worker/nodegroup joining the cluster. This, we need to create a cloudformation deployment and have the configmap/aws-auth updated based on the nodegroup we will be creating. This will allow the cluster acknowledge the nodegroup and join the cluster.

Let’s create a yaml file of cloudformation stack as followed, save the following file and put into your s3 bucket(create a new bucket and put the file into it, keep the path of the file with you):

Once uploaded, we will be creating our cloudformation, this time we are using terraform to create the stack for us and the code is as followed:

Note: fill up the details of vpc, subnet, eks-cluster-security group, path of your yaml location

Run the file and you should get your nodegroup created, now proceed with the arn output return by terraform as you create your nodegroup, you will need to replace the variable aws_nodegroup of your eks.tf .It should look like this:

That should leave you with the cluster of cost saving nodegroup. You may destroy the stack as you please and recreate when you need them. Note: if you were to delete them, please use terraform destroy in the order(nodegroup, cluster, vpc).

Where to go from here:

We have done the creation of spot instance ec2 instance joining our EKS cluster, but this could be improved with the newly announced EKS on spot instance. I will put them in the post in the time to come. Please do no hesitate to ask or give any recommendation on how to make my tutorial better.
🎅Ansible, 🎄Terraform, 🤶Chef : le père Noël existe-t-il vraiment ?
By: Marc Gardent
Tags: Azure Devops, Ansible, Iaac, Chef Infra, Terraform

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Rancher 2.5.3 and Syslog
By: Christian Frank
Tags: Syslog, Kubernetes, Terraform, Rancher

SUSE has recently released version 2.5 of Rancher. The new version brings a lot of improvements in the UI and under the hood.

One part that was completely revamped was the built-in applications, such as Monitoring and Logging. For Logging, Rancher went from a home-grown implementation of Fluentd to the Banzai Cloud Logging Operator, which is also based on Fluent Bit and Fluentd.

The configuration is quite different from the way it was before. It is very well documented in the Rancher Logging documentation; similar to syslog-ng, the configuration is built from Flows (i.e., sources) and Outputs (i.e., destinations).

In the selection for available outputs, however, Syslog is missing for the time being.

Cluster Output

As a workaround, the excellent documentation includes a YAML example to build a Fluentbit forwarder, based on Jacob Payne’s fluent-bit-out-syslog.

The Syslog forwarder is based on Fluent Bit v1.3.4 and can be configured in a secret as follows:

apiVersion: v1

kind: Secret

metadata:

name: syslog-config

namespace: cattle-logging-system

type: Opaque

stringData:

fluent-bit.conf: |

[INPUT]

Name forward

Port 24224

Buffer_Max_Size 524288

[OUTPUT]

Name syslog

InstanceName syslog-output

Match *

Addr rancher:514

Cluster true

SanitizeHost true

In this example, it’s a catch-all forward on the cluster level; I found it quite helpful to increase the buffer size from the default.

Important to note is that Fluent Bit uses TCP as the Syslog transport, not UDP — make sure your Syslog host allows TCP ingest and set the port accordingly.

Here’s a sample output record to prepare your parser:
Deploy and Manage an AWS VPC with Terraform
By: Nick Rondeau
Tags: Cloud Computing, DevOps, AWS, Cloud, Terraform

In this scenario, I am going to show you how to completely configure and deploy an AWS VPC with the aid of the powerful tool Terraform. Being Infrastructure as Code (IaC) this shows you just how easy it could be to replicate resources.

Feel free to follow along, I have uploaded all files to GitHub.

Here us the layout of the VPC we will be creating. It will host two EC2 instances, a webserver in a public subnet, and a Database in a private subnet.

The public subnet is accessable and all traffic is routed directly to the internet gateway we will be configuring.

The private subnet is completely cut off from the internet, all traffic in and out.

Verify your Terraform installation:

$ terraform --version

Terraform v0.14.2

Global Variables

Variables let us set some default values that are easily repeatable. This is setting up our region, even the AMI used for our EC2 instances.

AWS Provider

Now let’s set up our provider. This is rather straightforward, AWS is of course the provider and region refers to the variable previously defined.

VPC

This is where we lay out our entire VPC. We are setting up the public and private subnets. An Internet Gateway allows access to the internet. A route table contains a set of rules, called routes, that are used to determine where network traffic from your subnet or gateway is directed.

Multiple security groups are needed. The security group for our webserver allows our HTTP/HTTPS and SSH connections. Our Database security group enables MySQL port 3306, ping, and SSH from the public subnet.

Resources

We will need to set up some things for our EC2 instances. A key pair is needed to SSH to the instances that we are going to make. Then we define the AMI and configuration for the webserver, it is going to run a shell script which will install Apache Server for us. Lastly, we define our Database instance inside our private subnet.

This is the install script for Apache:

Now, it’s not good practices to keep your AWS keys in your Terraform files. We are going to set them as environment variables. Never store secrets in your Terraform files, especially if you intend to share them.

$ export AWS_ACCESS_KEY_ID="enter key without quotes"

$ export AWS_SECRET_ACCESS_KEY="enter key without quotes"

Now let’s run our Terraform code

$ terraform init

$ terraform validate

$ terraform plan

$ terraform apply

That’s it, now this can be replicated, built upon, whatever your heart desires. that is the magic of Terraform. We can now in a matter of minutes have this infrastructure completely built out.

$ terraform destroy

Don’t forget to destroy our creations to clean up. I hope you have enjoyed following along. If you want the code for this project, please check out GitHub. Thanks for reading.
Terraform Destroy: It’s Easy!
By: Riddhi Shree
Tags: AWS, Terraform, Infrastructure As Code

Whenever I use AWS services, my biggest concern after I am done using the services has always been —

Did I destroy all the resources properly, or, is there anything still left behind?

This was one of the main reasons why I got attracted towards Terraform. Terraform allows us to build and destroy (neatly) the entire infrastructure using just four simple commands —

terraform init terraform plan -out planfile terraform apply planfile terraform destroy

While working with Terraform, there are two important things that need to be taken care of:

All script files must end with the extension .tf Resource blocks must be used to describe one or more infrastructure objects

The syntax to create a resource is —

resource “<PROVIDER>_<TYPE>” “<NAME>” {[Configuration…]}

For example, if we want to create an EC2 instance, the corresponding resource block would be something similar to following —

AWS Instance Resource Block

In order to make the above code functional, a few more resource blocks would be required to be created for security group, IAM instance profile, IAM role inline policy, VPC, VPC subnet, VPC Internet Gateway, or for creating an association between a route table and a subnet, or, a route table and an internet gateway or virtual private gateway.

Security Group

IAM Instance Profile and IAM Role Policy

VPC Resource Block

VPC Subnet

VPC Internet Gateway

Resource to create an association between a route table and a subnet

Variables can be defined inside a variable block in two ways —

With a default value Without a default value

Define variables with or without a default value

If a default value has not been provided for a variable, then the user will be prompted to enter its value at runtime.

Once defined, the variables can be referenced inside a resource block or a provider block by using the var keyword.

Access variables

When you feel the script is ready, or if you just want to test your script, get ready to run a few commands.

Initialize the working directory by running terraform init command. Run terraform plan -out planfile to create an execution plan and save it in a file. After the command is run, any error in the Terraform script would be highlighted on the command line output. When you are happy with the generated plan, apply these changes by running the command terraform apply planfile Whenever you wish to tear down the infrastructure that was created by Terraform, without leaving behind any debris, run the command terraform destroy

Highlighted Error Messages

$ terraform plan -out planfile

$ terraform apply planfile

$ terraform destroy

The End!

References

Before I sign off, I am sharing below a few references that helped me in getting started with Terraform —

Troubleshooting
Time to DRY those IaC configurations with env0 and Terragrunt!
By: Tim Davis
Tags: Terragrunt, Automation, DevOps, Terraform

But, what does keeping your configurations “dry” mean? Having dry configs allows you to sanitize your terraform configuration files for use in multiple environments at once. Let’s say your code looks like this:

└── live

├── prod

│ ├── app

│ │ └── main.tf

│ ├── mysql

│ │ └── main.tf

│ └── vpc

│ └── main.tf

├── qa

│ ├── app

│ │ └── main.tf

│ ├── mysql

│ │ └── main.tf

│ └── vpc

│ └── main.tf

└── stage

├── app

│ └── main.tf

├── mysql

│ └── main.tf

└── vpc

└── main.tf

Each one of the environments have multiple components. In a traditional Terraform environment, you would have multiple sets of the same configuration files, that are all almost the same, but you have to edit the specific config info for each of the different environments. With Terragrunt, you can have “remote terraform configurations” where you store the clean terraform files in a separate repo, and then just call on it in remotely from any place you need it, and only put the Terragrunt configs for each specific environment in their corresponding place.

└── live

├── prod

│ ├── app

│ │ └── terragrunt.hcl

│ ├── mysql

│ │ └── terragrunt.hcl

│ └── vpc

│ └── terragrunt.hcl

├── qa

│ ├── app

│ │ └── terragrunt.hcl

│ ├── mysql

│ │ └── terragrunt.hcl

│ └── vpc

│ └── terragrunt.hcl

└── stage

├── app

│ └── terragrunt.hcl

├── mysql

│ └── terragrunt.hcl

└── vpc

└── terragrunt.hcl

This kind of operation can be very helpful when you have a lot of different environments or very complex environments at scale.

For more information on Terragrunt, check out our friends at Gruntwork. You can also find them on GitHub.

So how do I use it in env0?

This is the easiest part! You can set up your templates with your Terragrunt repo’s the same way you set up your Terraform repo’s today. Just click Create New Template as you normally would, and then select Terragrunt.
Terraform vs CloudFormation- Installation — Part 2
By: Amod Kadam
Tags: AWS, Installation, Cloudformation, Terraform

This is the Part 2 of the series — Terraform vs CloudFormation.

In the Part 1 of the series I have done high level comparison between Terraform and CloudFormation. The same is available at https://amod-kadam.medium.com/terraform-vs-cloudformation-part-1-75d54a999da5

In this blog post I will discuss about installing and setting up Terraform and AWS CLI toolset on Windows.

Setting up Terraform on Windows

The broad steps are outlined below.

Download appropriate package depending on OS and Architecture (32 bit/64 bit) from https://www.terraform.io/downloads.html Unzip it in any folder Terraform is available as a single binary Verify the installation by executing the following command. ( Adjust the PATH variables if you want to use Terraform from any other folder )

terraform version

5. To get help on Terraform

terraform help

If you want see this in action check out the following video.

Demo — Installing Terraform on Windows

If you are setting up Terraform on Linux you will get the appropriate instructions at https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started

Setting up AWS CLI on Windows

The broad steps are outlined below.

Download the AWS Command Line Interface (CLIv2) as MSI https://awscli.amazonaws.com/AWSCLIV2.msi Install using MSI Check the AWS CLI version

aws --version

4. Check AWS CloudFormation help

aws cloudformation help

You can refer the following video to see the installation in action.

Demo — Installing AWS CLI v2 on Windows

If you are using different OS then you will find relevant instructions at

Summary

The installation process is pretty straightforward in both the toolsets.

One key difference you will notice is that Terraform is available as a single binary whereas CloudFormation is having a set of files. If you ever need to move installation files from one location to another doing that in Terraform will be much easier.

Terraform consumes less space as compared to CloudFormation post installation.

AWS CLI can be used to work with other AWS services directly and and not limited to CloudFormation whereas Terraform is used for Infrastructure management.

In the next part of the series we will see how to use these toolsets to create actual resources in the AWS and compare and contrast the same !
Deploy the WordPress application on Kubernetes and AWS using terraform
By: Gyanesh Sharma
Tags: MySQL, WordPress, Kubernetes, AWS, Terraform

Statement of the task: Deploy the WordPress application on Kubernetes and AWS using terraform

Steps to perform task:

1. Write an Infrastructure as code using Terraform, which automatically deploy the WordPress application

2. On AWS, use RDS service for the relational database for WordPress application.

3. Deploy the WordPress as a container either on top of Minikube or EKS or Fargate service on AWS

4. The WordPress application should be accessible from the public world if deployed on AWS or through workstation if deployed on Minikube.

Tools and modules required to perform this task:

1.AWS CLI

2.Terraform

3.Kubectl

4. Minikube

Steps to perform:

Step 1: Create New Folder for this Task.( In cli.)

cd desktop

mkdir <name_of_folder_you_want>

cd <name_of_folder_you_want>

Step 2: Creating you First terraform <File_name>.tf

notepad main.tf

Step 3: Inside main.tf Create your code.

Create a provider.

provider "kubernetes" {

config_context_cluster = "minikube"

}

2. Create resource.

resource "kubernetes_deployment" "wordpresspod" {

metadata {

name = "wordpress"

}

3. Create specification and templates.

spec {

replicas = 2



selector {

match_labels = {

env = "dev"

region = "IN"

App = "wordpress"

}



}



template {

metadata {

labels = {

env = "dev"

region = "IN"

App = "wordpress"



}

}

4. Create WordPress with port 80.

spec {

container {

image = "wordpress:4.8-apache"

name = "wordpressdb"

}

}

}

}

}



port {

node_port = 32123

port = 80

target_port = 80

}



type = "NodePort"

}

}

This is the last snippet here creation of terraform file is complete. Combine all these snippets to form main.tf .

Step 4: Start Kubernetes services by starting minikibe:

minikube start

Step 5: Run following command to run terraform file. (This is for initializing terraform).

terraform init

Output of the above command is:

Step 6: Command to run and apply terraform code.

terraform apply

Command to check about the creation of PODs

kubectl get pods

Step 7: Create Another Terraform file for Database.

Command to create terraform file.

terraform task.tf

2. Terraform code for database.

provider "aws" {

region = "ap-south-1"

}

resource "aws_db_instance" "db" {



engine = "mysql"

engine_version = "5.7.30"

instance_class = "db.t2.micro"

allocated_storage = 10

name = "mydb"

username = "wordpress_user"

password = "rootroot"

port = "3306"

publicly_accessible = true

iam_database_authentication_enabled = true

vpc_security_group_ids = ["sg-067bf7843a162e7d9"]

tags = {

Name = "mysql"

}

}

Step 8: Command to get IP for WordPress.

minikube ip

Output of these command give you an IP, enter that IP to web browser and it will open WordPress.

Welcome page of WordPress will be open like this.

thank you
Automatically Backup your EC2 Instances using AWS Backups & Terraform
By: Shadab Ambat
Tags: Ec2, AWS, Cloud, Terraform, Backup

Overview

For a while, taking automated EC2 backups in AWS either involved using the Data Lifecycle Manager (DLM) or resorting to some CloudWatch trickery (using Events). Both had their pros and cons and got the job done, but neither felt like a full-fledged solution designed solely for backups. AWS probably realized this and released AWS Backups last year (2019).

In this article we’ll create a completely automated backup solution using AWS Backups and Terraform.

This article was written as part of Akatsuki’s 2020 Advent Calendar

Rather than boring you with any more overviews or other long explanations, let’s jump right into it shall we!

What we’ll do

We’ll automatically create scheduled Image backups of an EC2 instance

We’ll also set a lifecycle policy on the backups so they’re automatically deleted after a 1 week retention

We’ll create the entire infrastructure (including a target EC2 instance to backup) in Terraform so that it’s easy to maintain in future

Prerequisites

Before we start here are some prerequisites for those following along

Knowledge

Basic knowledge of Terraform

Basic working knowledge of AWS (or another cloud provider)

And as always, an open mind :)

Tools

Terraform

An AWS account and AWS CLI

Your favourite IDE or a Text Editor

I’ll be using a Mac for this article but it should be fairly easy for Windows users to adapt it to their environment

Note you’ll be charged for any resources you create! So please keep that in mind if you use terraform to create the infrastructure!

If you want to skip all the explanation and just see the code, the complete project can be found on GitHub

To keep things simple we’ll be using a local state in this article but the GitHub project contains a backend.tf file that can be uncommented and modified to save your state to S3 and to enable state locking

Ok let’s start! :)
terraform tempfile and adding tags to YAML files
By: Ismail Yenigül
Tags: Yaml, Cloudformation, Terraform

I am working on creating a CloudFormation stack with terraform resource.

I need to define tags in CloudFormation YAML file in addition to terraform resource.

I added the following lines to YAML template file to make it work.

%{~ if length(mytags) >0 ~}

Tags:

%{~ endif ~}

%{~ for tag_key, tag_value in mytags ~}

- Key: "${tag_key}"

Value: "${tag_value}"

%{~ endfor ~} You can see all details in my following gist and check https://www.terraform.io/docs/configuration/expressions/strings.html for strings and templatefile handling.

Ismail YENIGUL

Devops Engineer
Kubernetes installation with Terraform and Ansible
By: Cemal Y. Dalar
Tags: Ansible, Hetzner, Kubernetes, Terraform, Infrastructure As Code

Photo by Jon Tyson on Unsplash

So let’s start.. We will follow the official kubernetes documentation here and kubeadm tool. Here are the tools you will need,

Terraform https://www.terraform.io/

Ansible https://www.ansible.com/

A Hetzner Cloud API Token. https://console.hetzner.cloud/

The Repository https://github.com/cdalar/hcloud-iac

Kubernetes config will be have these components.

1 master, 3 worker nodes.

k8s version 1.18.10

docker as container service https://www.docker.com/

cilium as CNI component. https://cilium.io/

Hetzner Cloud Controller Manager. github-link

Hetzner csi driver so we can provision Persistence Volumes. github-link

This is NOT a production ready configuration but close. At least this is not a local test only environment. This can actually handle some load :)

Here are the step-by-step walk. Open a terminal/shell



> cd hcloud-iac

> terraform init

> sudo terraform apply

> ansible-playbook -i tf_hosts.yml playbooks/main.yml

> kubectl get nodes -o wide --kubeconfig config > git clone git@github.com :cdalar/hcloud-iac.git> cd hcloud-iac> terraform init> sudo terraform apply> ansible-playbook -i tf_hosts.yml playbooks/main.yml> kubectl get nodes -o wide --kubeconfig config

So,

Your kubernetes configuration file is in ../config and you can use it with kubectl as “kubeconfig” parameter without managing your contexts.

Your kubeadmin join command is in ../kubeadm_join.sh.. Of course it has a timeout and will expire.

Terraform script also add the servers ip addresses on your /etc/hosts file. That is the reason you need to run terraform apply with sudo.

So you can simply do,

> ssh root@master1

> ssh root@worker1

in order to login to master node. Because the script uses your public key you will not be asked for a password.

So to destroy everything if you need,

> terraform destroy

Have fun !! and please give your comments and claps :)
Variable Validation in Terraform
By: Ishu Singh
Tags: Regex, Cloud Computing, AWS, Iaac, Terraform

Introduction:

In this post we will deep dive into custom validation rules for input variables in terraform as well explained in official documentation.

For example, we have declared a variable in variable.tf file as :

variable "ami_id" {

type = string

description = " The id of machine image (AMI) to use for the server."

}

Now we add a validation rule to this variable block:

variable "ami_id" {

type = string

description = " The id of machine image (AMI) to use for the server."

validation {

condition = length(var.ami_id) > 4 && substr(var.ami_id, 0, 4) == "ami-"

error_message = "The ami_id value must be a valid AMI id, starting with \"ami-\"."

}

}

Next, we’ll use can function to validate below:

Boolean variables

variable "boolean_variable" {

type = bool

description = "Example to validate a boolean variable."

validation {

condition = can(regex("^([t][r][u][e]|[f][a][l][s][e])$",var.boolean_variable))

error = "The boolean_variable must be either true or false."

}

}

valid inputs : true || false

invalid inputs: tru, no, 0, 1, yes

IP address

variable "ip_address" {

type = string

description = "Example to validate IP address."

validation {

condition = can(regex("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",var.ip_address))

error_message = "Invalid IP address provided."

}

}

valid inputs : “10.10.60.181”

invalid inputs : “10.0.1.” , “10.40.0.256” , “10.0.10,180”

List of IP addresses

variable "ip_address_list" {

type = string

description = "Example to validate list of IP addresses."

validation {

condition = can([for ip in var.ip_address_list: regex("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", ip)])

error_message = "Incorrect IP."

}

}

valid inputs : [“10.40.0.16”, “10.60.0.17”, “10.50.0.18”]

invalid inputs: [“10.40.0.256”, “10.60.017”, “10.50,0.18”]

Note: Validation error message must be at least one full English sentence starting with an uppercase letter and ending with a period or question mark.

You can validate your regex here .

Thank you!
eurekaにおけるここ一年のTerraform Component Delivery Processの変化
By: Takashi Narikawa
Tags: AWS, Delivery, Eureka, Terraform

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
A Quick Guide to Terraform
By: Narmin Jamalova
Tags: Cloud Computing, Technology, DevOps, Terraform

In this article, we will explore what Terraform is, what its workflow looks like and how it can be applied in practice.

Terraform is …

A tool to manage your infrastructure as code, including:

storage,

compute instances,

networking, etc.

The term infrastructure as code means that all the needed resources will be managed through files (i.e. code) instead of manual configurations through an interface. So, infrastructure “becomes” some code and can be versioned, which allows it to be easily re-used, changed and shared.

Specifically, Terraform will generate a plan on how to reach the desired state of the infrastructure for your project and will then execute it. If any changes take place subsequently, incremental plans will be created and applied.

Terraform is awesome also because it is platform-agnostic — which makes it easy to re-use the infrastructure once you switch platforms for any reason.
The Oracle Cloud Developer Image — does it stack up?
By: Paul Guerin
Tags: Developer Image, Stack, Resource Manager, Oci, Terraform

Provision using the Oracle Cloud Resource Manager

All the magic starts with the Oracle Cloud Resource Manager.

Resource Manager is an Oracle Cloud Infrastructure service that allows you to automate the process of provisioning your Oracle Cloud Infrastructure resources.

The advantage of the Resource Manager is the stack.

The stack is effectively an imported Terraform script. The Terraform script will setup the compute instance, and the compute instance will contain all the tools pre-installed.

Using Terraform, Resource Manager helps you install, configure, and manage resources through the “infrastructure-as-code” model.

The first step is to go to the Resource Manager. Often the easiest way is to search for the Resource Manager in the search bar at the top of the webpage.

Create a Terraform stack with the ‘Create Stack’ button.

Now from the ‘sample solution’ then Architecture tab, choose the Development Kit Application.

The second step is to choose the configuration.

Oracle can create new SSH keys by default, however if you already have a pair of SSH keys that you want to reuse, then just browse for the public key file.

Choose ‘Next’ then ‘Create’ to create the stack for the Oracle Cloud Developer Image.

So the stack is present now — but there is a message:

This stack was created using an Oracle solution. To deploy the resources defined by this stack, go to Terraform Actions and select Apply.

When using Terraform from the command line, after initialising, you still need to apply the script to provision the infrastructure.

With a Resource Manager stack, the same Terraform concept applies.

Go to ‘Terraform Actions’ and select ‘Apply’.

A job will run, which will create the image.

There is a log, and the start of the log should look like the following:

Initializing modules...

- compute in modules/compute

- network in modules/network Initializing provider plugins... The following providers do not have any version constraints in configuration, so the latest version was installed. To prevent automatic upgrades to new major versions that may contain breaking changes, it is recommended to add version = "..." constraints to the corresponding provider blocks in configuration, with the constraint strings suggested below. *provider.oci: version = "~> 4.6"

*provider.tls: version = "~> 2.0" Terraform has been successfully initialized! ..

When the job is finished, the ‘Application Information’ tab will give you the IP address to use for the SSH login.
Retail therapy with MuShop — made with love by the Oracle A-Team Alumni
By: Paul Guerin
Tags: Stack, Mushop, Resource Manager, Oci, Terraform

MuShop — the Sample E-Commerce Application

The Sample E-Commerce Application is listed as:

Deploy a sample e-commerce application using Always Free Oracle Cloud resources

Fortunately installing the Sample E-Commerce Application in our Oracle Cloud Infrastructure is going to be easy when using the Resource Manager to create a stack to execute a Terraform script.

Start by ‘Create Stack’.

Now choose ‘Sample Solution’, then the Sample E-Commerce Application from the Architecture tab.

Next is the configuration — but if you are still using the Free Trial, then ensure the node count is 1, and not the default of 2.

Choosing the default of 2 will result in an error later in the process.

After choosing a node count of 1, you’ll be able to choose your preferred SSH option.

Then create the stack for the Sample E-Commerce Application.

The stack is present now — but there is a message:

This stack was created using an Oracle solution. To deploy the resources defined by this stack, go to Terraform Actions and select Apply.

Selecting apply will apply the Terraform script to create the Sample E-Commerce Application.

A job will run, which will provision the infrastructure and create the application.

The job only takes minutes to execute.

Reviewing the infrastructure used for the application, you should be able to confirm the following components:

one compute instance.

two object storage objects (one private, one public that contains images).

one VCN containing a public subnet.

one load balancer.

one 19c autonomous transaction processing database of size 20GB.

Even if you use the free trial, there is a daily automatic backup of the autonomous database. The daily automatic backup starts at around 9:55pm UTC, and because the database is small, only takes a few minutes to complete.

Note — that the backups can’t be used to restore if you are using a free trial account.

Performing manual backups is also possible, if you upgrade to a paid account.

Next — we need the IP address to connect to the application, but we’ll need to wait longer for this.
Configure Your Machine to Create Resources with Terraform
By: Garrett Sweeney
Tags: Cloud, AWS, Cli, Aws Iam, Terraform

Terraform, AWS IAM, and your Macintosh!

Ensure Terraform is installed

Check if Terraform is installed with the following command:

$ terraform -v Terraform v0.12.29.

Make sure you have Terraform v0.12+ (for my latest guides, at least. Terraform v0.12 was a breaking change).

Otherwise, follow HashiCorp’s Install Terraform Docs.

Ensure AWS CLI is Configured

Next, ensure that you have your AWS CLI credentials configured so Terraform can create resources in the proper AWS Account. I normally check with the AWS CLI’s Security Token Service Action, Get Caller Identity.

aws sts get-caller-identity

If all is configured correctly, you can expect something like the following:

{

"UserId": "<somevalue>",

"Account": "<somevalue>",

"Arn": "arn:aws:iam::<somevalue>:user/<somename>"

}

Otherwise, follow these instructions to Configure the AWS CLI.
Terraform “SkuNotAvailable” Message
By: Jack Roper
Tags: Terraform, Azure

When trying to create a VM in Azure using Terraform I was receiving this error message:

Error: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 — Original Error: autorest/azure: Service returned an error. Status= Code=”SkuNotAvailable” Message=”The requested size for resource ‘/subscriptions/x/resourceGroups/x/providers/Microsoft.Compute/virtualMachines/x’ is currently not available in location ‘ukwest’ zones ‘’ for subscription ‘x’. Please try another size or deploy to a different location or zones. See https://aka.ms/azureskunotavailable for details.”

Turns out the Standard_D1_v2 SKU i was trying to create was not enabled for the subscription in the ukwest region, confirmed by running the following:

az vm list-skus — location ukwest — output table ResourceType Locations Name Zones Capabilities Restrictions

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

hostGroups/hosts ukwest DSv3-Type1 [‘vCPUs=64’, ‘vCPUsPerCore=2’] None

hostGroups/hosts ukwest ESv3-Type1 [‘vCPUs=64’, ‘vCPUsPerCore=2’] None

hostGroups/hosts ukwest FSv2-Type2 [‘vCPUs=72’, ‘vCPUsPerCore=2’] None

None

Running:

az vm list-skus — location uksouth — output table`

Showed that the SKU Standard_D1_v2 i wanted was available. Annoying as I then had to change the subnetting and NICs to a different region.

To get the VM size available in UKWest it would be necessary to contact Microsoft to get them to enable it, as I was testing this was not necessary.
Terraform: How to avoid hard-coding of AWS account IDs?
By: Arunvel Sriram
Tags: AWS, Terraform

When using multiple AWS accounts it very likely that you will have hard-coded AWS account IDs all over your Terraform codebase. Hard-coding is annoying and prone to errors. For example, you could use the production AWS account ID instead of pre-production one by mistake. So its always better to have these account numbers defined somewhere and consumed by name.

The immediate solution to this is to extract them as variables. However, if your codebase is complex and involves tons of modules and terraform files then you will have to copy these variable definitions all over the modules and terraform files.

So, to overcome this we can extract these variable definitions into a module. But, how do we access these variables from another module or terraform file? We cannot, because variables defined inside a module are scoped. Here comes the power of Terraform output variables. Using output variables a module can expose data to its consumers.

Following the above, we can create a module called account_ids and store all the AWS account IDs as follows:

# example/modules/account_ids/main.tf



output "usermanagement" {

value = "123456789012"

}



output "tools" {

value = "123456789123"

}



output "project_a_pre_prod" {

value = "123456789456"

}



output "project_a_prod" {

value = "123456789789"

}

Now we can consume the above module and get access to the variables from another module or terraform file as shown below:

# example/main.tf



module "account_ids" {

source = "./modules/account_ids"

}



locals {

project_a_pre_prod = "${module.account_ids.project_a_pre_prod}"

project_a_prod = "${module.account_ids.project_a_prod}"

...

}



...

Following the above pattern, we can also extract global variables into a separate module.

I can think of one place where this solution will not work. Its the Terraform backend configuration. Terraform does not allow interpolation in the backend configuration. So if you need to use any account ID in the backend configuration you will have to hard-code it. There are some workarounds in GitHub issues maybe I will write about it in another post.
It’s notification time… Slack Notifications, that is!
By: Tim Davis
Tags: Automation, Slack, Terraform, DevOps

Hey, env0 fans! I have an awesome quick update for you, today. We’re happy to announce that we now support Slack notifications!

No doubt you have probably at least heard of slack before. I would even wager a guess that you are part of at least one Slack workspace, if not many! There are lots of apps and integrations with slack to help it be used as your one-stop-shop for all things with your teams. Well, as of right now, you can now enable env0 notifications right to any slack channel you want!

Above is an example of a series of notifications where I deployed two environments in two separate projects (Production and Development). Production waited for manual approval, while Development deployed automatically. Once I approved the Production deployment, it completed as well. This is great for productivity, and for making sure your deployments go well. You can also jump right to the deployment simply by clicking on the environment name inside the slack notification:

But, what happens if there is an error from the deployment? No sweat, we’ll drop that into slack, too!

All of this can be yours TODAY in the env0 platform! Want detailed instructions on how to set this up in your Slack workspace? Check out the product documentation here.