aws s3 bucket permission

I was getting this error when downloading a file from a S3 bucket. fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden Turns out to be a permission issue. Use –acl bucket-owner-full-control. # UPLOAD aws s3 cp file.txt s3://bucket-name/dir/ --acl bucket-owner-full-control upload: .\file.txt to s3://bucket-name/dir/fw.sh # DOWNLOAD aws s3 cp s3://bucket-name/dir/file.txt . --acl bucket-owner-full-control download: s3://bucket-name/dir/file.txt to .\file.txt You need to do for both upload and download.

February 16, 2021 · 1 min · ulysses

create a swap file

How to create a swap file. A 2GB swap file. dd if=/dev/zero of=/swapfile bs=1k count=2048k Activate. mkswap /swapfile chmod 0600 /swapfile systemctl daemon-reload swapon /swapfile To make swap permanent, add to /etc/fstab. /swapfile swap swap defaults 0 0 Check if swap is working. cat /proc/swaps free -h

February 16, 2021 · 1 min · ulysses

gcp firewall source service account

Here’s how to create a firewall from service account to service account. gcloud compute firewall-rules create "firewall-name" \ --description="firewall-description" \ --priority "1000" \ --direction INGRESS \ --action allow \ --network "network-name" \ --source-service-accounts="service@account.net" \ --target-service-accounts="service@account.net" \ --rules tcp:9001 Instead of source-range, it’s using source-service-accounts.

February 16, 2021 · 1 min · ulysses

aws spot instances running docker

I have an AMI with docker installed. Here’s how I launch a spot instance using Terraform. Here’s my Terraform script. terraform { required_providers { aws = { source = "hashicorp/aws" } } } provider "aws" { profile = "default" region = "us-east-1" } resource "aws_spot_instance_request" "docker" { ami = "ami-xxxxxxxxxxxxxxxx" spot_price = "0.0031" wait_for_fulfillment = "true" key_name = "servers" instance_type = "t3.micro" subnet_id = "subnet-xxxxxxxxxxxxxxxx" security_groups = ["sg-xxxxxxxxxxxxxxxxxx"] associate_public_ip_address = "true" user_data = I use “aws_ec2_tag” resource to tag the instance properly. ...

February 14, 2021 · 1 min · ulysses

reinstall kernel

How to reinstall the latest kernel and rebuild initramfs. Find the latest kernel. rpm -qa kernel kernel-3.10.0-1160.6.1.el7.x86_64 kernel-3.10.0-1160.11.1.el7.x86_64 Remove the kernel first, then reinstall. yum remove kernel-3.10.0-1160.6.1.el7.x86_64 yum install kernel-3.10.0-1160.6.1.el7.x86_64

February 9, 2021 · 1 min · ulysses

monitor disk performance

Here are a few utilities that monitor disk I/O performance. iostat -d 5 pidstat -dl 20 iotop --only The alternative is atop, which you can set to run every 10 seconds for 3 hours. The output can be viewed later. atop -a -w logfile.atop 10 10800 & Use atop to read the log file. atop -r /path/to/logfile.atop

February 4, 2021 · 1 min · ulysses

terraform gcp instance

Here’s a Terraform script for launching an instance in Google Cloud Platform. provider "google" { project = "project-id" region = "us-central1" zone = "us-central1-a" } resource "google_compute_instance" "wiki" { name = "wiki" machine_type = "n2-standard-1" zone = "us-central1-a" tags = ["web-server"] labels = { name = "wiki" environment = "development" } boot_disk { initialize_params { image = "centos-7-v20210122" } } network_interface { network = "default" access_config { } } service_account { email = "service-account@email.com" scopes = ["cloud-platform"] } } Here’s a few Terraform commands. ...

February 3, 2021 · 1 min · ulysses

cross account kms keys

If you have multiple AWS accounts, you can setup a customer-managed KMS (key management service) in the AWS Key Management Service, to secure requests or services between the two AWS accounts. The customer-managed KMS key is tied to an identity such as an IAM user or role. In addition to users and roles, other AWS accounts can be added to grant access. KMS can be symmetric or asymmetric. It’s symmetric be default. To grant access to the other account, you need to add the AWS Account Id to the key. It’s 12 digit number unique to each AWS account. ...

February 2, 2021 · 1 min · ulysses

install jekyll on amazon linux 2

Here’s the script to install Jekyll on Amazon Linux 2. #!/bin/bash sudo hostnamectl set-hostname jekyll sudo yum update -y sudo amazon-linux-extras install ruby2.4 -y sudo yum install ruby ruby-devel -y sudo yum groupinstall "Development Tools" -y sudo gem install bundler sudo gem install rdoc sudo gem update --system sudo gem install jekyll jekyll new myblog To start the Jekyll server. cd mysite jekyll build jekyll serve --host 0.0.0.0 Open your browser and point it to the external IP of your instance on port 4000. ...

February 2, 2021 · 1 min · ulysses

checking yum transaction logs

Check if package is on the system. rpm -q httpd httpd-2.4.6-97.el7.centos.x86_64 Check the history logs. yum history list Loaded plugins: fastestmirror ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 115 | System <unset> | 2021-02-01 03:40 | Update | 1 114 | System <unset> | 2021-02-01 02:03 | I, U | 10 113 | System <unset> | 2021-01-29 19:54 | Update | 1 112 | System <unset> | 2021-01-21 14:41 | Update | 1 </unset></unset></unset></unset> Check detail transaction id. ...

February 1, 2021 · 1 min · ulysses