Skip to content

Instantly share code, notes, and snippets.

View lvthillo's full-sized avatar

Lorenz Vanthillo lvthillo

  • Antwerp, Belgium
View GitHub Profile
@lvthillo
lvthillo / scaling.yml
Last active June 10, 2019 15:06
Scaling Policy and Alarms
ScaleUpPolicy:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
AdjustmentType: ChangeInCapacity
AutoScalingGroupName: !Ref ASG
Cooldown: '1'
ScalingAdjustment: 1
ScaleDownPolicy:
Type: AWS::AutoScaling::ScalingPolicy
@lvthillo
lvthillo / ConfigSet.yml
Last active June 10, 2019 17:20
ConfigSets
# Definition of json configuration of AmazonCloudWatchAgent
02_config-amazon-cloudwatch-agent:
files:
'/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json':
content: !Sub |
{
"metrics": {
"append_dimensions": {
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
"ImageId": "${!aws:ImageId}",
@lvthillo
lvthillo / asg-resources.yml
Last active June 7, 2019 17:02
LaunchConfigurationReferences
ASGInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
InstanceProfileName: AGInstanceProfile
Roles:
- !Ref ASGRole
ASGRole:
Type: AWS::IAM::Role
Properties:
@lvthillo
lvthillo / LaunchConfiguration.yml
Last active June 10, 2019 15:06
LaunchConfiguration
ASGLaunchConfiguration:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
ImageId: !FindInMap
- RegionMap
- !Ref 'AWS::Region'
- HVM64
InstanceType: t2.micro
KeyName: !Ref SSHKey
LaunchConfigurationName: ASGLaunchConfiguration
@lvthillo
lvthillo / autoscalinggroup.yml
Last active June 6, 2019 19:39
Auto Scaling Group
ASG:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
AvailabilityZones: !GetAZs ''
AutoScalingGroupName: auto-scaling-group
LaunchConfigurationName: !Ref ASGLaunchConfiguration
MaxSize: '5'
MinSize: '1'
@lvthillo
lvthillo / Subnets
Created February 27, 2019 18:17
Subnets
Parameters:
Region:
Type: String
Default: eu-west-1
AllowedValues:
- eu-west-1
- eu-west-2
- eu-west-3
- eu-central-1
- us-west-2
@lvthillo
lvthillo / VPC
Created February 27, 2019 18:12
VPC
Parameters:
VPCCidr:
AllowedPattern: '((\d{1,3})\.){3}\d{1,3}/\d{1,2}'
Type: String
Default: 10.0.0.0/16
Description: Enter the CIDR for your VPC
...
Resources:
VPC:
Type: AWS::EC2::VPC
@lvthillo
lvthillo / application-role-trust-policy.json
Created December 23, 2018 18:15
Assume role policy document
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::123456789012:root" },
"Action": "sts:AssumeRole"
}
}
@lvthillo
lvthillo / policy-document-2.json
Created December 23, 2018 18:06
AWS IAM Policy Document to allow to put S3 object
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject"
],
"Resource": "arn:aws:s3:::demo-lvthillo-bucket/*"
}
@lvthillo
lvthillo / policy-document-1.json
Last active December 23, 2018 17:58
AWS IAM Policy Document to allow user to assume role
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:ListRoles",
"sts:AssumeRole"
],
"Resource": "*"