$ apt update
$ apt search awscli
$ apt install curl wget unzip -y
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
$ unzip awscliv2.zip
$ ./aws/install
$ aws --version
aws-cli/2.1.28 Python/3.8.8 Linux/4.19.121-linuxkit exe/x86_64.ubuntu.20 prompt/off
Change into our working directory:
$ mkdir -p myworkdir/src
$ cd myworkdir
Create a virtual env:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: 0.2 | |
| env: | |
| variables: | |
| TERRAFORM_VERSION: "0.14.7" | |
| phases: | |
| install: | |
| commands: | |
| - curl -o "terraform.zip" https://releases.hashicorp.com/terraform/"$TERRAFORM_VERSION"/terraform_"$TERRAFORM_VERSION"_linux_amd64.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # inspired by: | |
| # https://unix.stackexchange.com/a/193568 | |
| # source function library | |
| . /etc/init.d/functions | |
| # application name | |
| APP="node_exporter" | |
| DESC="Node Exporter" |
provider.tf:
$ cat provider.tf
provider "aws" {
version = "~> 2.0"
region = "eu-west-1"
profile = "dev"
shared_credentials_file = "~/.aws/credentials"
}
In BASH:
# usage: ./pushover-notify home-pc "homepc notification"
#!/bin/bash
APP_TOKEN='x'
USER_TOKEN='x'
TITLE="$1"
MESSAGE="$2"
curl 'https://api.pushover.net/1/messages.json' -X POST -d "token=$APP_TOKEN&user=$USER_TOKEN&message=\"$MESSAGE\"&title=$TITLE"
Return random string from array:
#!/usr/bin/env bash
subnets[0]="subnet1"
subnets[1]="subnet2"
subnets[2]="subnet3"
size=${#subnets[@]}
index=$(($RANDOM % $size))
Download:
curl -O -L "https://github.com/grafana/agent/releases/latest/download/agent-linux-amd64.zip";
unzip "agent-linux-amd64.zip";
chmod a+x "agent-linux-amd64";
Move to place:
$ docker build -t local:flask .
$ docker run -it -p 8080:8080 local:flask
$ python app_test.py
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
$ curl http://localhost:5000/metrics
# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 317.0
python_gc_objects_collected_total{generation="1"} 71.0
python_gc_objects_collected_total{generation="2"} 0.0
# HELP python_gc_objects_uncollectable_total Uncollectable object found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0