Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'json'
def read_json(file_name)
JSON.parse(File.read(file_name))
end
def parse(iam)
result = []
@fujiwara
fujiwara / gist:c33927f5b03007c0fdeedd171488e5e5
Last active May 14, 2021 18:05
ecspresso handbook diff between v1.3 and v1.5.4
diff --git a/books/ecspresso-handbook/codedeploy.md b/books/ecspresso-handbook/codedeploy.md
index 7204de5..e68c4ea 100644
--- a/books/ecspresso-handbook/codedeploy.md
+++ b/books/ecspresso-handbook/codedeploy.md
@@ -185,9 +185,9 @@ https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/userguide/deployment-type-blu
Blue/Green デプロイを設定したサービスは、オートスケーリングが有効な状態ではデプロイが行えません。
-`ecspresso deploy --suspend-autoscaling` を指定することで、デプロイ前に Application Autoscaling を一時的に停止できます。
+`ecspresso deploy --suspend-auto-scaling` を指定することで、デプロイ前に Application Autoscaling を一時的に停止できます。
aws ecs describe-task-definition --task-definition ecspresso-test --include TAGS | jq '. | {containerDefinitions:.taskDefinition.containerDefinitions, cpu:.taskDefinition.cpu, executionRoleArn:.taskDefinition.executionRoleArn, family:.taskDefinition.family, memory:.taskDefinition.memory, networkMode:.taskDefinition.networkMode, placementConstraints:.taskDefinition.placementConstraints, requiresCompatibilities:.taskDefinition.requiresCompatibilities, taskRoleArn:.taskDefinition.taskRoleArn, proxyConfiguration:.taskDefinition.proxyConfiguration, volumes:.taskDefinition.volumes, tags:.tags}'
@fujiwara
fujiwara / config.yml
Created February 21, 2020 05:39
aws-cli-v2 orb
orbs:
aws-cli-v2:
commands:
install:
steps:
- run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
@fujiwara
fujiwara / fluentd.conf
Last active February 7, 2020 13:00
fix fluentd tags from firelens
<match *-firelens-*>
@type firelens_tag_filter
</match>
<match app.firelens.**>
# ...
</match>
@fujiwara
fujiwara / graph-depends-on.pl
Created May 29, 2019 05:51
Visualize container dependencies from ECS task definition JSON.
#!/usr/bin/env perl
use 5.12.1;
use warnings;
use JSON::PP;
my $file = shift;
open my $in, "<", $file or die $!;
my $taskdef = JSON::PP::decode_json(do { local $/ = undef; <$in> });
my $g = $file;
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use 5.014;
use Encode;
use JSON::PP qw/encode_json decode_json/;
use Sys::Hostname;
use IPC::Open2;
@fujiwara
fujiwara / index.js
Created February 22, 2019 03:22
Lambda Edge redirector
exports.handler = async (event, context, callback) => {
const response = {
status: "302",
statusDescription: "Found",
headers: {
location: [{
key: 'Location',
value: 'http://contents.xj-storage.jp/xcontents/AS01527/ec0b38f1/7c8b/4dbc/89e1/106de9ea3108/20190108140352250s.pdf',
}],
}
@fujiwara
fujiwara / main.go
Created February 18, 2019 10:06
cloudwatch-to-mackerel
package main
import (
"context"
"encoding/json"
"errors"
"log"
"os"
"time"
@fujiwara
fujiwara / main.go
Created February 15, 2019 15:07
Convert GetMetricData results to Mackerel metric format.
package main
import (
"encoding/json"
"fmt"
"os"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"