Skip to content

Instantly share code, notes, and snippets.

View toricls's full-sized avatar
🐔
Cock a doodle doo

Tori Hara toricls

🐔
Cock a doodle doo
View GitHub Profile
@toricls
toricls / Time-based-auto-scaling-on-fargate.md
Created August 5, 2019 01:49
Example: Time-based Auto Scaling on Amazon ECS + AWS Fargate

Set parameters

$ export ECS_CLUSTER_NAME={YOUR_ECS_CLUSTER_NAME}
$ export ECS_SERVICE_NAME={YOUR_ECS_SERVICE_NAME}

RegisterScalableTarget

@toricls
toricls / enable-ci-for-ecs.sh
Last active August 31, 2019 07:38
Enable CloudWatch Container Insights for ALL existing ECS clusters in a region
#!/usr/bin/env bash
set -eu
aws ecs list-clusters \
| jq -r '.clusterArns[]' \
| xargs -I '{}' aws ecs update-cluster-settings --cluster '{}' --settings name=containerInsights,value=enabled
@toricls
toricls / time-to-redemption.yaml
Created November 13, 2019 02:57
CloudFormation Existing Resource Import で利用するテンプレートの例 see also https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import.html
AWSTemplateFormatVersion: 2010-09-09
Description: It's time to redemption
Resources:
# これが罪深くも過去に手で作られた IAM ユーザー (Import の対象)
MyHandCraftedIAMUser:
Type: AWS::IAM::User
DeletionPolicy: Retain
# こちらは CFn でちゃんと作る IAM グループ
MyCFnCreatedIAMGroup:
@toricls
toricls / SF-Fargate-Task.md
Last active April 29, 2021 13:39
Resilient Fargate task scheduling with Step Functions and EventBridge

image

@toricls
toricls / app-runner-template.yml
Created May 19, 2021 06:57
AWS App Runner CloudFormation Template generated using AWS Copilot
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
AWSTemplateFormatVersion: 2010-09-09
Description: CloudFormation template that represents a request driven web service on AWS App Runner.
Parameters:
AppName:
Type: String
EnvName:
Type: String
WorkloadName:
@toricls
toricls / move-aws-containers-to-top.user.js
Last active June 2, 2021 03:28
AWS Containers please 🙏 - A Greasemonkey script
// ==UserScript==
// @name AWS Containers please 🙏
// @namespace https://aws.amazon.com
// @include /^https:\/\/[a-z0-9.-]*console\.aws\.amazon\.com\/.*$/
// @version 0.0.1
// @author toricls
// ==/UserScript==
(function() {
window.setTimeout(update, 1000);
@toricls
toricls / state-machine.json
Created June 18, 2021 07:29
Step Functions example state machine - retrying by stoppedReason of ECS task
{
"Version": "1.0",
"Comment": "Run AWS Fargate task",
"TimeoutSeconds": 900,
"StartAt": "Run Fargate Task",
"States": {
"Run Fargate Task": {
"Type": "Task",
"Resource": "arn:aws:states:::ecs:runTask.sync",
"Parameters": {
@toricls
toricls / screenshots.applescript
Created June 29, 2021 01:15
Take screenshots with consistent size and location with AppleScript in Automator.app
set theDate to do shell script "date +%Y_%m_%d_%H%M%S"
set theDirectory to POSIX path of (path to desktop)
set thePath to theDirectory & "screenCapture_" & theDate & ".png"
# -R557,308,810,513 is the rectangle option: x,y,w,h
do shell script "screencapture -R557,308,810,513 -tpng" & space & quoted form of thePath
@toricls
toricls / Dockerfile
Last active March 2, 2025 00:33
Docker-in-Docker with Amazon Linux 2 Container
FROM amazonlinux:2
RUN yum -y update \
# systemd is not a hard requirement for Amazon ECS Anywhere, but the installation script currently only supports systemd to run.
# Amazon ECS Anywhere can be used without systemd, if you set up your nodes and register them into your ECS cluster **without** the installation script.
&& yum -y install systemd \
&& yum clean all
RUN cd /lib/systemd/system/sysinit.target.wants/; \
for i in *; do [ $i = systemd-tmpfiles-setup.service ] || rm -f $i; done
@toricls
toricls / Dockerfile
Created July 19, 2021 04:46
Docker-in-Docker with Ubuntu Container
FROM ubuntu:20.04
RUN set -ex \
&& apt update \
&& apt install --no-install-recommends -y \
ca-certificates curl docker.io \
# systemd is not a hard requirement for Amazon ECS Anywhere, but the installation script currently only supports systemd to run.
# Amazon ECS Anywhere can be used without systemd, if you set up your nodes and register them into your ECS cluster **without** the installation script.
systemd init \
&& rm -rf /var/lib/apt/lists/* \