serverless-plugin-module-registry 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,110 @@
1
+ Resources:
2
+ # Stream Processor Lambda Role
3
+ StreamProcessorRole:
4
+ Type: AWS::IAM::Role
5
+ Properties:
6
+ RoleName: ${self:provider.stackName}-${self:provider.region}-stream-processor
7
+ AssumeRolePolicyDocument:
8
+ Version: '2012-10-17'
9
+ Statement:
10
+ - Effect: Allow
11
+ Principal:
12
+ Service: lambda.amazonaws.com
13
+ Action: sts:AssumeRole
14
+ ManagedPolicyArns:
15
+ - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
16
+ Policies:
17
+ - PolicyName: StreamProcessorPolicy-${self:provider.region}
18
+ PolicyDocument:
19
+ Version: '2012-10-17'
20
+ Statement:
21
+ - Effect: Allow
22
+ Action:
23
+ - dynamodb:DescribeStream
24
+ - dynamodb:GetRecords
25
+ - dynamodb:GetShardIterator
26
+ - dynamodb:ListStreams
27
+ Resource:
28
+ - !Sub 'arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${param:tableName}/stream/*'
29
+ - Effect: Allow
30
+ Action:
31
+ - sqs:SendMessage
32
+ - sqs:GetQueueUrl
33
+ Resource: !GetAtt RoleUpdateQueue.Arn
34
+ - Effect: Allow
35
+ Action:
36
+ - events:PutEvents
37
+ Resource: !GetAtt ModuleRegistryEventBus.Arn
38
+
39
+ # Role Updater Lambda Role
40
+ RoleUpdaterRole:
41
+ Type: AWS::IAM::Role
42
+ Properties:
43
+ RoleName: ${self:provider.stackName}-${self:provider.region}-role-updater
44
+ AssumeRolePolicyDocument:
45
+ Version: '2012-10-17'
46
+ Statement:
47
+ - Effect: Allow
48
+ Principal:
49
+ Service: lambda.amazonaws.com
50
+ Action: sts:AssumeRole
51
+ ManagedPolicyArns:
52
+ - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
53
+ Policies:
54
+ - PolicyName: RoleUpdaterPolicy-${self:provider.region}
55
+ PolicyDocument:
56
+ Version: '2012-10-17'
57
+ Statement:
58
+ - Effect: Allow
59
+ Action:
60
+ - sqs:ReceiveMessage
61
+ - sqs:DeleteMessage
62
+ - sqs:GetQueueAttributes
63
+ Resource: !GetAtt RoleUpdateQueue.Arn
64
+ - Effect: Allow
65
+ Action:
66
+ - dynamodb:Query
67
+ - dynamodb:GetItem
68
+ Resource:
69
+ - !Sub 'arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${param:tableName}'
70
+ - !Sub 'arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${param:tableName}/index/*'
71
+ - Effect: Allow
72
+ Action:
73
+ - iam:ListRoles
74
+ - iam:GetRole
75
+ - iam:TagRole
76
+ - iam:UntagRole
77
+ - iam:AttachRolePolicy
78
+ - iam:DetachRolePolicy
79
+ - iam:ListAttachedRolePolicies
80
+ - iam:ListPolicies
81
+ Resource: '*'
82
+ - Effect: Allow
83
+ Action:
84
+ - cloudwatch:PutMetricData
85
+ Resource: '*'
86
+
87
+ # Stream Enabler Custom Resource Lambda Role
88
+ StreamEnablerRole:
89
+ Type: AWS::IAM::Role
90
+ Properties:
91
+ RoleName: ${self:provider.stackName}-${self:provider.region}-stream-enabler
92
+ AssumeRolePolicyDocument:
93
+ Version: '2012-10-17'
94
+ Statement:
95
+ - Effect: Allow
96
+ Principal:
97
+ Service: lambda.amazonaws.com
98
+ Action: sts:AssumeRole
99
+ ManagedPolicyArns:
100
+ - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
101
+ Policies:
102
+ - PolicyName: StreamEnablerPolicy-${self:provider.region}
103
+ PolicyDocument:
104
+ Version: '2012-10-17'
105
+ Statement:
106
+ - Effect: Allow
107
+ Action:
108
+ - dynamodb:DescribeTable
109
+ - dynamodb:UpdateTable
110
+ Resource: !Sub 'arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${param:tableName}'
@@ -0,0 +1,13 @@
1
+ # Additional Outputs (table outputs are in dynamodb.yml, queue outputs in sqs.yml)
2
+ Outputs:
3
+ StreamProcessorRoleArn:
4
+ Description: Stream Processor Lambda Role ARN
5
+ Value: !GetAtt StreamProcessorRole.Arn
6
+ Export:
7
+ Name: ${self:provider.stackName}-StreamProcessorRoleArn
8
+
9
+ RoleUpdaterRoleArn:
10
+ Description: Role Updater Lambda Role ARN
11
+ Value: !GetAtt RoleUpdaterRole.Arn
12
+ Export:
13
+ Name: ${self:provider.stackName}-RoleUpdaterRoleArn
@@ -0,0 +1,57 @@
1
+ Resources:
2
+ # Dead Letter Queue
3
+ RoleUpdateDLQ:
4
+ Type: AWS::SQS::Queue
5
+ Properties:
6
+ QueueName: ${self:provider.stackName}-role-update-dlq
7
+ MessageRetentionPeriod: 1209600 # 14 days
8
+ Tags:
9
+ - Key: Purpose
10
+ Value: ModuleRegistryRoleUpdateDLQ
11
+ - Key: Service
12
+ Value: ${self:service}
13
+ - Key: Stage
14
+ Value: ${self:provider.stage}
15
+
16
+ # Main Queue with DLQ
17
+ RoleUpdateQueue:
18
+ Type: AWS::SQS::Queue
19
+ Properties:
20
+ QueueName: ${self:provider.stackName}-role-update-queue
21
+ MessageRetentionPeriod: 1209600 # 14 days
22
+ VisibilityTimeout: 900 # 15 minutes (matches Lambda max timeout)
23
+ RedrivePolicy:
24
+ deadLetterTargetArn: !GetAtt RoleUpdateDLQ.Arn
25
+ maxReceiveCount: 3
26
+ Tags:
27
+ - Key: Purpose
28
+ Value: ModuleRegistryRoleUpdate
29
+ - Key: Service
30
+ Value: ${self:service}
31
+ - Key: Stage
32
+ Value: ${self:provider.stage}
33
+
34
+ Outputs:
35
+ RoleUpdateQueueArn:
36
+ Description: Role Update Queue ARN
37
+ Value: !GetAtt RoleUpdateQueue.Arn
38
+ Export:
39
+ Name: ${self:provider.stackName}-QueueArn
40
+
41
+ RoleUpdateQueueUrl:
42
+ Description: Role Update Queue URL
43
+ Value: !Ref RoleUpdateQueue
44
+ Export:
45
+ Name: ${self:provider.stackName}-QueueUrl
46
+
47
+ RoleUpdateDLQArn:
48
+ Description: Dead Letter Queue ARN
49
+ Value: !GetAtt RoleUpdateDLQ.Arn
50
+ Export:
51
+ Name: ${self:provider.stackName}-DLQArn
52
+
53
+ RoleUpdateDLQUrl:
54
+ Description: Dead Letter Queue URL
55
+ Value: !Ref RoleUpdateDLQ
56
+ Export:
57
+ Name: ${self:provider.stackName}-DLQUrl
@@ -0,0 +1,69 @@
1
+ service: ${param:serviceName}-infra
2
+
3
+ frameworkVersion: '4'
4
+
5
+ provider:
6
+ name: aws
7
+ runtime: nodejs20.x
8
+ stage: ${opt:stage, 'dev'}
9
+ region: ${opt:region, 'us-east-1'}
10
+ stackName: ${param:stackName}
11
+ memorySize: 256
12
+ timeout: 30
13
+ logRetentionInDays: 14
14
+ deploymentMethod: direct # Use direct deployment to avoid change sets
15
+
16
+ params:
17
+ live:
18
+ deletionPolicy: Retain
19
+ default:
20
+ serviceName: module-registry
21
+ stackName: ${self:service}-${self:provider.stage}
22
+ tableName: 'module-registry-${self:provider.stage}'
23
+ policyPrefix: ''
24
+ accountId: ''
25
+ deletionPolicy: Delete
26
+
27
+ # plugins:
28
+ # - serverless-plugin-artifact-manager
29
+
30
+ functions:
31
+ streamProcessor:
32
+ handler: handlers/stream-processor.handler
33
+ role: StreamProcessorRole
34
+ timeout: 60
35
+ memorySize: 512
36
+ environment:
37
+ QUEUE_URL: !Ref RoleUpdateQueue
38
+ EVENT_BUS_NAME: !Ref ModuleRegistryEventBus
39
+ events:
40
+ - stream:
41
+ type: dynamodb
42
+ arn: !GetAtt EnableTableStreams.StreamArn
43
+ batchSize: 10
44
+ startingPosition: LATEST
45
+ filterPatterns:
46
+ - eventName: [INSERT, MODIFY, REMOVE]
47
+
48
+ roleUpdater:
49
+ handler: handlers/role-updater.handler
50
+ role: RoleUpdaterRole
51
+ timeout: 900 # 15 min max
52
+ memorySize: 1024
53
+ environment:
54
+ DYNAMODB_TABLE_NAME: ${param:tableName}
55
+ POLICY_PREFIX: ${param:policyPrefix}
56
+ AWS_ACCOUNT_ID: ${param:accountId}
57
+ events:
58
+ - sqs:
59
+ arn: !GetAtt RoleUpdateQueue.Arn
60
+ batchSize: 10
61
+
62
+ resources:
63
+ - ${file(resources/dynamodb.yml)}
64
+ - ${file(resources/custom-stream-enabler.yml)}
65
+ - ${file(resources/eventbridge.yml)}
66
+ - ${file(resources/iam.yml)}
67
+ - ${file(resources/sqs.yml)}
68
+ - ${file(resources/cloudwatch.yml)}
69
+ - ${file(resources/outputs.yml)}