Skip to content

Commit

Permalink
Update pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rezabekf committed Dec 5, 2024
1 parent ad9f335 commit a95be92
Show file tree
Hide file tree
Showing 31 changed files with 183 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
python-version: '3.x'
cache: 'pip' # caching pip dependencies
- run: pip install -r requirements.txt
- run: pip install pre-commit
- uses: actions/cache@v3
env:
cache-name: pre-commit
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:

# General
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: detect-private-key
Expand All @@ -30,13 +30,13 @@ repos:

# CloudFormation
- repo: https://github.com/aws-cloudformation/cfn-lint
rev: v0.79.7
rev: v1.20.2
hooks:
- id: cfn-lint-rc
files: code/solutions/.*\.(ya?ml|template)$

- repo: https://github.com/aws-cloudformation/rain
rev: v1.4.4
rev: v1.19.0
hooks:
- id: cfn-format
files: code/solutions/.*\.(ya?ml|template)$
Expand All @@ -55,27 +55,27 @@ repos:

# Python
- repo: https://github.com/pycqa/pylint
rev: v3.0.0a7
rev: v3.3.2
hooks:
- id: pylint
args:
- --errors-only
- --disable=E0401

- repo: https://github.com/psf/black
rev: 23.7.0
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]

# Shell check
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.5
rev: v0.10.0.1
hooks:
- id: shellcheck
files: solutions/.*\.(sh)$
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,22 @@ Resources:
Properties:
DesiredCapacity: 2
LaunchTemplate:
LaunchTemplateId: !Ref 'LaunchTemplate'
LaunchTemplateId: !Ref LaunchTemplate
Version: !GetAtt LaunchTemplate.LatestVersionNumber
MaxSize: 4
MinSize: 2
Tags:
- Key: Name
PropagateAtLaunch: true
Value: !Ref 'NameTagValue'
Value: !Ref NameTagValue
- Key: AppName
PropagateAtLaunch: true
Value: !Ref 'AppNameTagValue'
Value: !Ref AppNameTagValue
- Key: Env
PropagateAtLaunch: true
Value: !Ref 'Env'
Value: !Ref Env
TargetGroupARNs:
- !Ref 'TargetGroup'
- !Ref TargetGroup
VPCZoneIdentifier:
- !ImportValue
Fn::Sub: ${NetworkStackName}-PrivateSubnet1Id
Expand All @@ -126,9 +126,9 @@ Resources:
Properties:
DefaultActions:
- Order: 1
TargetGroupArn: !Ref 'TargetGroup'
TargetGroupArn: !Ref TargetGroup
Type: forward
LoadBalancerArn: !Ref 'LoadBalancer'
LoadBalancerArn: !Ref LoadBalancer
Port: 80
Protocol: HTTP

Expand Down Expand Up @@ -188,8 +188,8 @@ Resources:
ensureRunning: true
Properties:
LaunchTemplateData:
ImageId: !Ref 'LatestAmiId'
InstanceType: !Ref 'InstanceType'
ImageId: !Ref LatestAmiId
InstanceType: !Ref InstanceType
SecurityGroupIds:
- !ImportValue
Fn::Sub: ${SecurityGroupStackName}-AppInstancesSecurityGroupId
Expand All @@ -203,11 +203,11 @@ Resources:
- ResourceType: launch-template
Tags:
- Key: Name
Value: !Ref 'NameTagValue'
Value: !Ref NameTagValue
- Key: AppName
Value: !Ref 'AppNameTagValue'
Value: !Ref AppNameTagValue
- Key: Env
Value: !Ref 'Env'
Value: !Ref Env

LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Expand All @@ -224,11 +224,11 @@ Resources:
Fn::Sub: ${NetworkStackName}-PublicSubnet2Id
Tags:
- Key: Name
Value: !Ref 'NameTagValue'
Value: !Ref NameTagValue
- Key: AppName
Value: !Ref 'AppNameTagValue'
Value: !Ref AppNameTagValue
- Key: Env
Value: !Ref 'Env'
Value: !Ref Env
Type: application

RecordSet:
Expand All @@ -242,9 +242,9 @@ Resources:
Fn::Sub: ${HostedZoneStackName}-HostedZoneId
Name: !ImportValue
Fn::Sub: ${HostedZoneStackName}-HostedZoneName
SetIdentifier: !Sub '${AppNameTagValue} application managed with the ${AWS::StackName} stack.'
SetIdentifier: !Sub ${AppNameTagValue} application managed with the ${AWS::StackName} stack.
Type: A
Weight: !Ref 'RecordSetWeight'
Weight: !Ref RecordSetWeight

TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Expand All @@ -259,11 +259,11 @@ Resources:
Protocol: HTTP
Tags:
- Key: Name
Value: !Ref 'NameTagValue'
Value: !Ref NameTagValue
- Key: AppName
Value: !Ref 'AppNameTagValue'
Value: !Ref AppNameTagValue
- Key: Env
Value: !Ref 'Env'
Value: !Ref Env
TargetType: instance
UnhealthyThresholdCount: 2
VpcId: !ImportValue
Expand All @@ -272,4 +272,4 @@ Resources:
Outputs:
AppUrl:
Description: URL of the sample app.
Value: !Sub 'http://${LoadBalancer.DNSName}'
Value: !Sub http://${LoadBalancer.DNSName}
5 changes: 4 additions & 1 deletion code/solutions/conditions/condition-resource-property.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ Resources:
Type: AWS::EC2::Instance
Properties:
ImageId: !Ref LatestAmiId
InstanceType: !If [IsProduction, t2.small, t2.micro]
InstanceType: !If
- IsProduction
- t2.small
- t2.micro
10 changes: 8 additions & 2 deletions code/solutions/cross-stacks/ec2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,18 @@ Resources:
SubnetId: !ImportValue cfn-workshop-PublicSubnet1
IamInstanceProfile: !ImportValue cfn-workshop-WebServerInstanceProfile
ImageId: !Ref AmiID
InstanceType: !FindInMap [EnvironmentToInstanceType, !Ref EnvironmentType, InstanceType]
InstanceType: !FindInMap
- EnvironmentToInstanceType
- !Ref EnvironmentType
- InstanceType
SecurityGroupIds:
- !Ref WebServerSecurityGroup
Tags:
- Key: Name
Value: !Join [' ', [!Ref EnvironmentType, Web Server]]
Value: !Join
- ' '
- - !Ref EnvironmentType
- Web Server
UserData: !Base64
Fn::Sub: |
#!/bin/bash -xe
Expand Down
8 changes: 6 additions & 2 deletions code/solutions/cross-stacks/vpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ Resources:
Properties:
CidrBlock: !Ref PublicSubnet1Cidr
VpcId: !Ref VPC
AvailabilityZone: !Select [0, !Ref AvailabilityZones]
AvailabilityZone: !Select
- 0
- !Ref AvailabilityZones
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Expand Down Expand Up @@ -86,7 +88,9 @@ Resources:
Properties:
CidrBlock: !Ref PublicSubnet2Cidr
VpcId: !Ref VPC
AvailabilityZone: !Select [1, !Ref AvailabilityZones]
AvailabilityZone: !Select
- 1
- !Ref AvailabilityZones
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Expand Down
4 changes: 4 additions & 0 deletions code/solutions/dynamic-references/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Resources:
rules_to_suppress:
- id: F80
- id: F27
cfn-lint:
config:
ignore_checks:
- W1011
Properties:
DBInstanceClass: db.t3.micro
AllocatedStorage: "20"
Expand Down
5 changes: 4 additions & 1 deletion code/solutions/dynamic-references/ec2-instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Resources:
Instance:
Type: AWS::EC2::Instance
Properties:
AvailabilityZone: !Select ["0", !GetAZs ""]
AvailabilityZone: !Select
- 0
- !GetAZs
Ref: AWS::Region
InstanceType: t2.micro
ImageId: '{{resolve:ssm:/golden-images/amazon-linux-2}}'
2 changes: 1 addition & 1 deletion code/solutions/dynamic-references/lambda-function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Resources:
- lambda.amazonaws.com
Version: "2012-10-17"
ManagedPolicyArns:
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Path: /

DatabaseFunction:
Expand Down
2 changes: 1 addition & 1 deletion code/solutions/dynamic-references/lambda-memory-size.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Resources:
- lambda.amazonaws.com
Version: "2012-10-17"
ManagedPolicyArns:
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Path: /

HelloWorldFunction:
Expand Down
10 changes: 8 additions & 2 deletions code/solutions/helper-scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,18 @@ Resources:
Properties:
IamInstanceProfile: !Ref WebServerInstanceProfile
ImageId: !Ref AmiID
InstanceType: !FindInMap [EnvironmentToInstanceType, !Ref EnvironmentType, InstanceType]
InstanceType: !FindInMap
- EnvironmentToInstanceType
- !Ref EnvironmentType
- InstanceType
SecurityGroupIds:
- !Ref WebServerSecurityGroup
Tags:
- Key: Name
Value: !Join ['-', [!Ref EnvironmentType, webserver]]
Value: !Join
- '-'
- - !Ref EnvironmentType
- webserver
UserData: !Base64
Fn::Sub: |
#!/bin/bash -xe
Expand Down
5 changes: 4 additions & 1 deletion code/solutions/intrinsic-functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Resources:
InstanceType: !Ref InstanceType
Tags:
- Key: Name
Value: !Join ['-', [!Ref InstanceType, webserver]]
Value: !Join
- '-'
- - !Ref InstanceType
- webserver
- Key: InstanceType
Value: !Sub ${InstanceType}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Metadata:
Parameters:
DeletionPolicyParameter:
Type: String
AllowedValues: [Delete, Retain]
AllowedValues:
- Delete
- Retain
Default: Delete

LatestAmiId:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Metadata:
Parameters:
DeletionPolicyParameter:
Type: String
AllowedValues: [Delete, Retain]
AllowedValues:
- Delete
- Retain
Default: Delete

LatestAmiId:
Expand All @@ -32,11 +34,15 @@ Resources:
widgets:
- type: metric
x: 0
"y": 7
y: 7
width: 3
height: 3
properties:
metrics: [[AWS/EC2, CPUUtilization, InstanceId, !Ref EC2Instance]]
metrics:
- - AWS/EC2
- CPUUtilization
- InstanceId
- !Ref EC2Instance
period: 300
stat: Average
region: !Ref AWS::Region
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Metadata:
Parameters:
DeletionPolicyParameter:
Type: String
AllowedValues: [Delete, Retain, Snapshot]
AllowedValues:
- Delete
- Retain
- Snapshot
Default: Delete

Transform: AWS::LanguageExtensions
Expand All @@ -34,11 +37,17 @@ Resources:
widgets:
- type: metric
x: 0
"y": 7
y: 7
width: 3
height: 3
properties:
metrics: [[AWS/S3, NumberOfObjects, StorageType, AllStorageTypes, BucketName, !Ref S3Bucket]]
metrics:
- - AWS/S3
- NumberOfObjects
- StorageType
- AllStorageTypes
- BucketName
- !Ref S3Bucket
period: 86400
region: !Ref AWS::Region
title: S3 objects
Expand Down
4 changes: 3 additions & 1 deletion code/solutions/looping-over-collections/s3-buckets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Transform: AWS::LanguageExtensions
Resources:
Fn::ForEach::S3Buckets:
- S3BucketLogicalId
- [S3Bucket1, S3Bucket2, S3Bucket3]
- - S3Bucket1
- S3Bucket2
- S3Bucket3
- ${S3BucketLogicalId}:
Type: AWS::S3::Bucket
Properties:
Expand Down
Loading

0 comments on commit a95be92

Please sign in to comment.