If you would like to get more detailed overview when using terraform plan, you can turn trace logging on by setting setting the environment variable TF_LOG to a non-zero value, e.g. export TF_LOG=1 or TF_LOG=1 terraform plan
asdf and terraform (or vault or packer)
Using the asdf version manager to manage versions of various binaries like terraform, vault or packer is easily done by following the instructions below:
- Download and install asdf if you haven’t got it already (https://asdf-vm.com/#/core-manage-asdf)
- If you want to install the latest version of terraform for example do the following:
asdf plugin add terraform asdf install terraform latest asdf global terraform 0.14.9 asdf list terraform 0.14.9 terraform --version Terraform v0.14.9
Renaming multiple files in linux
Problem
You would like to rename multiple files, replacing some text with something else (like replacing Pixies_The with Pixies).
Solution
Install the rename utility
sudo apt install rename
and replace the text as follows
cd folder_to_rename_files rename 's/Pixies_The/Pixies/g' **
Get/Set platform information
To get or set in environment variables the platform information of a system you can use the following:
export ARCH=$(case $(arch) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(arch) ;; esac)
export OS=$(uname | awk '{print tolower($0)}')Taken from the installation instructions of the Operator SKD here: https://master.sdk.operatorframework.io/docs/installation/
Upgrading node and yarn
Problem
You are getting the following error when trying to use yarn:
$ yarn yarn install v1.21.1 [1/5] Validating package.json... error xxxxx@: The engine "node" is incompatible with this module. Expected version "^10.0.0". Got "8.10.0" error Found incompatible module. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Solution
Upgrade yarn
$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - [sudo] password for username: OK $ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list deb https://dl.yarnpkg.com/debian/ stable main $ sudo apt-get update $ sudo apt-get upgrade
Which should give the updated yarn version:
$ yarn yarn install v1.22.5 [1/5] Validating package.json... error xxxxx@: The engine "node" is incompatible with this module. Expected version "^10.0.0". Got "8.10.0" error Found incompatible module. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Upgrade node version with the correct version from above (ie 10.0.0)
$ curl -fsSL https://deb.nodesource.com/setup_10.x | sudo -E bash - $ sudo apt-get install -y nodejs .... The following packages will be upgraded: nodejs ...
And then the needed versions would have been installed:
$ yarn yarn install v1.22.5 [1/5] Validating package.json... [2/5] Resolving packages... success Already up-to-date. Done in 0.90s.
Forcing https with wordpress on dreamhost
In order to be able to force the http to https redirection when using wordpress in dreamhost use the following (taken from https://help.dreamhost.com/hc/en-us/articles/215747758-Force-your-site-to-load-securely-with-an-htaccess-file) :
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Header always set Content-Security-Policy "upgrade-insecure-requests;"
# BEGIN WordPress
.....
# END WordPressLinux disabling a service on bootup
To stop having a service automatically start after bootup in a Linux system with systemctl use the following to stop and then disable the service:
sudo systemctl stop service_name sudo systemctl disable service_name
Using port number in Terraform output
Problem
You would like to output some additional information (ie port number) in addition to the variable provided by Terraform.
Solution
Use interpolation of the Terraform variable using ${var} together with the rest of the string you would like to output, like:
output "kibana_endpoint" {
value = "http://${aws_instance.elasticsearch.public_ip}:5601"
description = "The Kibana endpoint"
}More information about the language https://learn.hashicorp.com/tutorials/terraform/outputs?in=terraform/configuration-language
docker rmi image_name V docker image rm image_name
There is a newer way of using the command, as it is also the case in a few other docker commands.
Even though both the command can be used to remove a docker image, the command using docker image rm is the most recent way of using it.
Creating two types of IAM users in AWS using the CLI
To create a user in AWS IAM using the CLI (after you have configured it), use the following:
Create a user with programmatic access (access key ID and secret access key):
$ aws iam create-user \
--user-name User_Prog_Access
Response:
{
"User": {
"Path": "/",
"UserName": "User_Prog_Access",
"UserId": "AIDExampleUserId",
"Arn": "arn:aws:iam::123333333:user/User_Prog_Access",
"CreateDate": "2021-01-29T12:20:43+00:00"
}
}
$ aws iam create-access-key \
--user-name User_Prog_Access
Response:
{
"AccessKey": {
"UserName": "User_Prog_Access",
"AccessKeyId": "AKIExampleAccessKeyID",
"Status": "Active",
"SecretAccessKey": "ttExampleSecretAccessKey",
"CreateDate": "2021-01-29T12:21:22+00:00"
}
}
And for a user with console access:
$ aws iam create-user \
--user-name User_Console_Access
Response:
{
"User": {
"Path": "/",
"UserName": "User_Console_Access",
"UserId": "AIExampleUserId",
"Arn": "arn:aws:iam::933323111111:user/User_Console_Access",
"CreateDate": "2021-01-29T12:31:46+00:00"
}
}
$ aws iam create-login-profile \
--user-name User_Console_Access \
--password Temp_Password4 \
--password-reset-required
Response:
{
"LoginProfile": {
"UserName": "User_Console_Access",
"CreateDate": "2021-01-29T12:35:28+00:00",
"PasswordResetRequired": true
}
}