Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cloudformation/output_changeset_as_markdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ create_changeset=`aws cloudformation create-change-set \
--change-set-name $changeset_name \
--template-body file://$PWD/cloudformation/vpc.yaml`

sleep 10
sleep 15

changeset_id=$(echo ${create_changeset} | jq -r .Id)
changeset_json=$(aws cloudformation describe-change-set --change-set-name $changeset_id)
changes=$(echo "$changeset_json" | jq -r .Changes)
changes_length=$(echo "$changes" | jq length)

echo "<details><summary><code>$stack_name ($changes_length changes)</code></summary>" # クリックで展開できるやつ
echo "<code>$stack_name ($changes_length changes)</code>"
echo
if [ $changes_length -gt 0 ]; then
echo '|Action|論理ID|物理ID|リソースタイプ|置換|' # 少しでも横幅を減らすためにActionだけ英語
Expand All @@ -30,9 +30,9 @@ for i in $( seq 0 $(($changes_length - 1)) ); do
echo "|$col_1|$col_2|$col_3|$col_4|$col_5|"
done
fi
echo '<ul><li><details><summary>view json</summary>' # インデントを付ける目的でリストにしている
echo '<details>'
echo
echo '```json'
echo "$changeset_json"
echo '```'
echo '</details></li></ul></details>'
echo '</details>'
20 changes: 17 additions & 3 deletions cloudformation/vpc.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
AWSTemplateFormatVersion: 2010-09-09

Parameters:
VpcCIDR:
Type: String
Default: ''
# Default: 10.1.0.0/16
PublicSubnetCIDR:
Type: String
Default: ''
# Default: 10.1.3.0/24
PrivateSubnetCIDR:
Type: String
Default: ''
# Default: 10.1.4.0/24

Resources:
CfVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.1.0.0/16
CidrBlock: !Ref VpcCIDR
Tags:
-
Key: Name
Expand All @@ -13,7 +27,7 @@ Resources:
CfPublicSubnet:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: 10.1.1.0/24
CidrBlock: !Ref PublicSubnetCIDR
MapPublicIpOnLaunch: true
VpcId: !Ref CfVPC
AvailabilityZone: ap-northeast-1a
Expand All @@ -23,7 +37,7 @@ Resources:
CfPrivateSubnet:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: 10.1.2.0/24
CidrBlock: !Ref PrivateSubnetCIDR
MapPublicIpOnLaunch: false
VpcId: !Ref CfVPC
AvailabilityZone: ap-northeast-1c
Expand Down