Skip to content

Commit

Permalink
Merge pull request #423 from kddejong/community/format/cleanup
Browse files Browse the repository at this point in the history
Fix scripts calling bash and format community yml files
  • Loading branch information
kddejong authored Apr 26, 2024
2 parents d9acfab + 2b842a2 commit 8be06da
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 40 deletions.
64 changes: 30 additions & 34 deletions community/services/Lambda/LambdaSample.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
AWSTemplateFormatVersion: '2010-09-09'
AWSTemplateFormatVersion: "2010-09-09"

Description: Template for Lambda Sample.

Parameters:
EnvName:
Type: String
Description: Name of an environment. 'dev', 'staging', 'prod' and any name.
Type: String
AllowedPattern: ^.*[^0-9]$
ConstraintDescription: Must end with non-numeric character.
LambdaHandlerPath:

LambdaHandlerPath:
Description: Path of a Lambda Handler.
Type: String
Description: Path of a Lambda Handler.
AllowedPattern: ^.*[^0-9]$
ConstraintDescription: Must end with non-numeric character.
Outputs:
LambdaRoleARN:
Description: Role for Lambda execution.
Value:
Fn::GetAtt:
- LambdaRole
- Arn
Export:
Name: LambdaRole
LambdaFunctionName:
Value:
Ref: LambdaFunction
LambdaFunctionARN:
Description: Lambda function ARN.
Value:
Fn::GetAtt:
- LambdaFunction
- Arn
Export:
Name:
Fn::Sub: LambdaARN-${EnvName}

Resources:
LambdaRole:
Type: AWS::IAM::Role
Expand All @@ -40,23 +23,23 @@ Resources:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Version: 2012-10-17
- lambda.amazonaws.com
Version: "2012-10-17"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AWSLambdaExecute
- arn:aws:iam::aws:policy/AmazonS3FullAccess
- arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess
- arn:aws:iam::aws:policy/AmazonKinesisFullAccess
Path: /

LambdaFunction:
Type: AWS::Lambda::Function
Properties:
FunctionName:
Fn::Sub: lambda-function-${EnvName}
FunctionName: !Sub lambda-function-${EnvName}
Description: LambdaFunction using python3.12.
Runtime: python3.12
Code:
Expand All @@ -69,11 +52,24 @@ Resources:
Handler: !Sub ${LambdaHandlerPath}
MemorySize: 128
Timeout: 10
Role:
Fn::GetAtt:
- LambdaRole
- Arn
Role: !GetAtt LambdaRole.Arn
Environment:
Variables:
ENV: !Ref EnvName
TZ: UTC

Outputs:
LambdaRoleARN:
Description: Role for Lambda execution.
Value: !GetAtt LambdaRole.Arn
Export:
Name: LambdaRole

LambdaFunctionName:
Value: !Ref LambdaFunction

LambdaFunctionARN:
Description: Lambda function ARN.
Value: !GetAtt LambdaFunction.Arn
Export:
Name: !Sub LambdaARN-${EnvName}
2 changes: 1 addition & 1 deletion scripts/create-json-all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/usr/bin/env bash
#
SCRIPT_DIR=$(dirname "$0")
find . -name "*.yaml" | xargs -n1 "${SCRIPT_DIR}/create-json-single.sh"
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-json-single.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/usr/bin/env bash
name=$(echo $1 | sed s/\.yaml/\.json/g)
echo Creating $name based on $1
rain fmt -j $1 > ${name}
2 changes: 1 addition & 1 deletion scripts/format-yaml-all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/usr/bin/env bash
#
set -eou pipefail

Expand Down
4 changes: 1 addition & 3 deletions scripts/format-yaml-single.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/local/bin/bash
#!/usr/bin/env bash
set -eou pipefail
echo $1
n=$(basename $1)
rain fmt $1 > /tmp/$n
mv /tmp/$n $1


0 comments on commit 8be06da

Please sign in to comment.