Goal: There is a directory "/opt/application" where the archive with the application is downloaded and unpacked into a directory where the short derivative of the HASH commit (8 characters) is used as the name. And a symbolic link is created to this directory. It is necessary to store only the 3 latest versions of the …
Continue reading " Ansible – Store N recent directories and artifacts"
This script gets a list of all directories in the bucket and deletes all objects in each directory, except for the last "N" specified. To run the script, you need to pass two arguments: Bucket name Number of last stored objects How to use it: main.py:
The answer was taken from gitmemory In order to encrypt an already created EBS Volume, you need to take a snapshot of it. Then, from the created snapshot, create a disk in the same region as the original one, and also specify the KMS key for encryption. Then we save the manifest of the current …
Continue reading " EKS – Encrypt current PV (EBS Volume)"
For a parameterized assembly with an image tag selection, you will need the Active Choices plugin Go to "Manage Jenkins" Section "Manage Plugins" Go to the "Available" tab and select "Active Choices" in the search. Install it. You also need plugins: Database PostgreSQL Database Create a "New Item" – "Pipeline", indicate that it …
Continue reading " Jenkins – Active Choice: PostgreSQL – Return result of SELECT query"
To automatically generate a "Sign-in URL" to a newly added Control Tower account, you will need the following: create a Lambda function on the master account (the region must be us-east-1 – Virginia, so we will use CloudTrail as a trigger); create a policy that allows you to assign a role and attach it to …
Continue reading " AWS Organization – Automatic adding Sign-in URL for new accounts"
In order to allow read access from the S3 Bucket for all members included in the organization, the following policy must be applied to the S3 Bucket: Where "stackset-lambdas" is the S3 Bucket name and "o-xxxxxxxxxx" is your Organization ID.
This Python script gets a list of all regions, finds EC2 instances, RDS instances and ASG in them, and if there is no "prevent_stop" tag equal to "true" on the resource, then it stops this resource, and in the case of ASG it scaledown it to 0. main.py: List of required permissions to run …
Continue reading "Lambda – For stopping EC2 instances, RDS instances and ASG downscale in all regions"
This Python script creates events in PagerDuty using APIv2. The following script was taken as a basis. First you need to create a "Routing Key", aka "Integration Key", not to be confused with "API Access Key", which can be used for any API calls, we only need a key from a specific service. Go to …
Continue reading "PagerDuty – Python script for creating events"
AWS Transfer supports 3 protocols: SFTP, FTP, and FTPS. And only SFTP can have a public endpoint, FTP/FTPS can only be run inside a VPC. Also for login/password authorization, you must use a custom provider, you can find more information about this here. Goal: Create an AWS Transfer server for the FTP protocol, the service …
Continue reading "AWS Transfer – Public FTP"
To remove all unused images, you can use the following command: