Skip to content

Commit

Permalink
refactor: Ensure use of modern iam.role syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Nov 10, 2021
1 parent 3c8a2e3 commit 156bfae
Show file tree
Hide file tree
Showing 26 changed files with 293 additions and 246 deletions.
2 changes: 1 addition & 1 deletion aws-ffmpeg-layer/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
service: gifmaker
frameworkVersion: ">=1.34.0 <2.0.0"
frameworkVersion: ">=2.24.0"

provider:
name: aws
Expand Down
55 changes: 28 additions & 27 deletions aws-golang-dynamo-stream-to-elasticsearch/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,34 @@ provider:
environment:
ELASTICSEARCH_URL:
Fn::GetAtt: ["PuppySearch", "DomainEndpoint"]

iamRoleStatements:
- Effect: Allow
Action:
- 'dynamodb:ListTables'
- 'dynamodb:DescribeTable'
- 'dynamodb:DescribeStream'
- 'dynamodb:ListStreams'
- 'dynamodb:GetShardIterator'
- 'dynamodb:BatchGetItem'
- 'dynamodb:GetItem'
- 'dynamodb:Query'
- 'dynamodb:Scan'
- 'dynamodb:DescribeReservedCapacity'
- 'dynamodb:DescribeReservedCapacityOfferings'
- 'dynamodb:GetRecords'
Resource:
- { "Fn::GetAtt": ["PuppyDemo", "Arn"] }
- Effect: Allow
Action:
- es:ESHttpPost
- es:ESHttpPut
- es:ESHttpDelete
- es:ESHttpGet
Resource:
- { "Fn::GetAtt": ["PuppySearch", "DomainArn"] }
- { "Fn::Join": ["", ["Fn::GetAtt": ["PuppySearch", "DomainArn"], "/*"]] }
iam:
role:
statements:
- Effect: Allow
Action:
- 'dynamodb:ListTables'
- 'dynamodb:DescribeTable'
- 'dynamodb:DescribeStream'
- 'dynamodb:ListStreams'
- 'dynamodb:GetShardIterator'
- 'dynamodb:BatchGetItem'
- 'dynamodb:GetItem'
- 'dynamodb:Query'
- 'dynamodb:Scan'
- 'dynamodb:DescribeReservedCapacity'
- 'dynamodb:DescribeReservedCapacityOfferings'
- 'dynamodb:GetRecords'
Resource:
- { "Fn::GetAtt": ["PuppyDemo", "Arn"] }
- Effect: Allow
Action:
- es:ESHttpPost
- es:ESHttpPut
- es:ESHttpDelete
- es:ESHttpGet
Resource:
- { "Fn::GetAtt": ["PuppySearch", "DomainArn"] }
- { "Fn::Join": ["", ["Fn::GetAtt": ["PuppySearch", "DomainArn"], "/*"]] }

package:
exclude:
Expand Down
32 changes: 17 additions & 15 deletions aws-golang-googlemap/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ service: gomapservice # NOTE: update this with your service name
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
frameworkVersion: ">=1.28.0 <2.0.0"
frameworkVersion: ">=2.24.0"

provider:
name: aws
Expand All @@ -29,20 +29,22 @@ provider:
region: ap-southeast-1

# you can add statements to the Lambda function's IAM Role here
# iamRoleStatements:
# - Effect: "Allow"
# Action:
# - "s3:ListBucket"
# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
# - Effect: "Allow"
# Action:
# - "s3:PutObject"
# Resource:
# Fn::Join:
# - ""
# - - "arn:aws:s3:::"
# - "Ref" : "ServerlessDeploymentBucket"
# - "/*"
# iam:
# role:
# statements:
# - Effect: "Allow"
# Action:
# - "s3:ListBucket"
# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
# - Effect: "Allow"
# Action:
# - "s3:PutObject"
# Resource:
# Fn::Join:
# - ""
# - - "arn:aws:s3:::"
# - "Ref" : "ServerlessDeploymentBucket"
# - "/*"

# you can define service wide environment variables here
# environment:
Expand Down
33 changes: 18 additions & 15 deletions aws-golang-http-get-post/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ service: goservice # NOTE: update this with your service name
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
frameworkVersion: ">=1.28.0 <2.0.0"
frameworkVersion: ">=2.24.0"

provider:
name: aws
Expand All @@ -26,21 +26,24 @@ provider:
# stage: dev
# region: us-east-1


# you can add statements to the Lambda function's IAM Role here
# iamRoleStatements:
# - Effect: "Allow"
# Action:
# - "s3:ListBucket"
# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
# - Effect: "Allow"
# Action:
# - "s3:PutObject"
# Resource:
# Fn::Join:
# - ""
# - - "arn:aws:s3:::"
# - "Ref" : "ServerlessDeploymentBucket"
# - "/*"
# iam:
# role:
# statements:
# - Effect: "Allow"
# Action:
# - "s3:ListBucket"
# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
# - Effect: "Allow"
# Action:
# - "s3:PutObject"
# Resource:
# Fn::Join:
# - ""
# - - "arn:aws:s3:::"
# - "Ref" : "ServerlessDeploymentBucket"
# - "/*"

# you can define service wide environment variables here
# environment:
Expand Down
24 changes: 13 additions & 11 deletions aws-golang-rest-api-with-dynamodb/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
app: aws-golang-rest-api-with-dynamodb
service: aws-golang-rest-api-with-dynamodb

frameworkVersion: ">=1.1.0 <=2.1.1"
frameworkVersion: ">=2.24.0"

provider:
name: aws
runtime: go1.x
environment:
DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"

functions:
create:
Expand Down
22 changes: 12 additions & 10 deletions aws-golang-s3-file-replicator/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
service: aws-golang-s3-file-replicator
frameworkVersion: ">=1.28.0 <2.0.0"
frameworkVersion: ">=2.24.0"

custom:
inputBucket: replicator-input-101
Expand All @@ -12,15 +12,17 @@ provider:
region: ap-northeast-1
memorySize: 128
timeout: 30
iamRoleStatements:
- Effect: Allow
Action:
- s3:*
Resource: "arn:aws:s3:::${self:custom.outputBucket}/*"
- Effect: Allow
Action:
- s3:*
Resource: "arn:aws:s3:::${self:custom.inputBucket}/*"
iam:
role:
statements:
- Effect: Allow
Action:
- s3:*
Resource: "arn:aws:s3:::${self:custom.outputBucket}/*"
- Effect: Allow
Action:
- s3:*
Resource: "arn:aws:s3:::${self:custom.inputBucket}/*"

package:
exclude:
Expand Down
26 changes: 14 additions & 12 deletions aws-node-dynamodb-backup/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ provider:
name: aws
runtime: nodejs12.x
stage: staging
iamRoleStatements:
- Effect: Allow
Action:
- s3:PutObject
Resource: "arn:aws:s3:::${self:custom.bucket}/${self:custom.prefix}/${self:custom.dynamoDBTableName}/*"
- Effect: Allow
Action:
- "dynamodb:GetRecords"
- "dynamodb:GetShardIterator"
- "dynamodb:DescribeStream"
- "dynamodb:ListStreams"
Resource: "arn:aws:dynamodb:ap-southeast-1:*:table/${self:custom.dynamoDBTableName}/stream/*"
iam:
role:
statements:
- Effect: Allow
Action:
- s3:PutObject
Resource: "arn:aws:s3:::${self:custom.bucket}/${self:custom.prefix}/${self:custom.dynamoDBTableName}/*"
- Effect: Allow
Action:
- "dynamodb:GetRecords"
- "dynamodb:GetShardIterator"
- "dynamodb:DescribeStream"
- "dynamodb:ListStreams"
Resource: "arn:aws:dynamodb:ap-southeast-1:*:table/${self:custom.dynamoDBTableName}/stream/*"

functions:
backup:
Expand Down
16 changes: 9 additions & 7 deletions aws-node-fetch-file-and-store-in-s3/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
service: fetch-file-and-store-in-s3

frameworkVersion: ">=1.1.0"
frameworkVersion: ">=2.24.0"

custom:
bucket: <your-bucket-name>
Expand All @@ -10,12 +10,14 @@ provider:
runtime: nodejs12.x
stage: dev
region: us-west-1
iamRoleStatements:
- Effect: Allow
Action:
- s3:PutObject
- s3:PutObjectAcl
Resource: "arn:aws:s3:::${self:custom.bucket}/*"
iam:
role:
statements:
- Effect: Allow
Action:
- s3:PutObject
- s3:PutObjectAcl
Resource: "arn:aws:s3:::${self:custom.bucket}/*"

functions:
save:
Expand Down
3 changes: 2 additions & 1 deletion aws-node-graphql-and-rds/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ provider:
stage: dev
memorySize: 256
runtime: nodejs12.x
role: LambdaRole
iam:
role: LambdaRole
environment:
#aurora
AURORA_HOST: ${self:custom.AURORA.HOST}
Expand Down
14 changes: 8 additions & 6 deletions aws-node-graphql-api-with-dynamodb/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ provider:
runtime: nodejs10.x
environment:
DYNAMODB_TABLE: ${self:service}-${self:provider.stage}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:UpdateItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:UpdateItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"

functions:
query:
Expand Down
14 changes: 8 additions & 6 deletions aws-node-recursive-function/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ custom:
provider:
name: aws
runtime: nodejs12.x
# iamRoleStatements:
# - Effect: "Allow"
# Action:
# - "lambda:InvokeFunction"
# Resource: ${self:custom.functionARN}
# iam:
# role:
# statements:
# - Effect: "Allow"
# Action:
# - "lambda:InvokeFunction"
# Resource: ${self:custom.functionARN}

functions:
recursiveExample:
handler: handler.recursiveLambda
handler: handler.recursiveLambda
21 changes: 11 additions & 10 deletions aws-node-rekognition-analysis-s3-image/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ provider:
timeout: 10
stage: dev
region: us-east-1

iamRoleStatements:
- Effect: Allow
Action:
- s3:*
Resource: "*"
- Effect: "Allow"
Action:
- "rekognition:*"
Resource: "*"
iam:
role:
statements:
- Effect: Allow
Action:
- s3:*
Resource: "*"
- Effect: "Allow"
Action:
- "rekognition:*"
Resource: "*"

functions:
imageAnalysis:
Expand Down
Loading

0 comments on commit 156bfae

Please sign in to comment.