Skip to content

Commit 5949500

Browse files
committed
code
1 parent 55563c0 commit 5949500

File tree

3 files changed

+35
-204
lines changed

3 files changed

+35
-204
lines changed

cloudformation/iam.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Resources:
3737
- secretsmanager:GetSecretValue
3838
Effect: Allow
3939
Resource:
40-
- Fn::Sub: arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:infra-core-api-config
40+
- Fn::Sub: arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:infra-core-api-config*
4141

4242
- Action:
4343
- dynamodb:DescribeLimits
@@ -79,14 +79,19 @@ Resources:
7979
- dynamodb:DescribeTable
8080
- dynamodb:DeleteItem
8181
- dynamodb:GetItem
82-
- dynamodb:Scan
8382
- dynamodb:Query
8483
- dynamodb:UpdateItem
8584
Resource:
8685
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-cache
8786
Condition:
88-
StringNotLike:
89-
"dynamodb:LeadingKeys": "entra_*"
87+
ForAllValues:StringEquals:
88+
dynamodb:LeadingKeys:
89+
- testing # add any keys that must be accessible
90+
ForAllValues:StringLike:
91+
dynamodb:Attributes:
92+
- primaryKey
93+
- expireAt
94+
- "*"
9095

9196
- Sid: DynamoDBIndexAccess
9297
Effect: Allow
@@ -122,13 +127,9 @@ Resources:
122127
Principal:
123128
Service:
124129
- lambda.amazonaws.com
125-
- Action:
126-
- sts:AssumeRole
127-
Effect: Allow
128-
Resource: !GetAtt EntraLambdaIAMRole.Arn
129130

130131
Policies:
131-
- PolicyName: lambda-sqs
132+
- PolicyName: lambda-generic
132133
PolicyDocument:
133134
Version: "2012-10-17"
134135
Statement:
@@ -152,6 +153,12 @@ Resources:
152153
Principal:
153154
Service:
154155
- lambda.amazonaws.com
156+
- Effect: Allow
157+
Principal:
158+
AWS:
159+
- Fn::GetAtt: ApiLambdaIAMRole.Arn
160+
Action:
161+
- sts:AssumeRole
155162
Policies:
156163
- PolicyName: lambda-get-entra-secret
157164
PolicyDocument:
@@ -161,11 +168,10 @@ Resources:
161168
- secretsmanager:GetSecretValue
162169
Effect: Allow
163170
Resource:
164-
- Fn::Sub: arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:infra-core-api-entra
171+
- Fn::Sub: arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:infra-core-api-entra*
165172
- Action:
166173
- dynamodb:BatchGetItem
167174
- dynamodb:GetItem
168-
- dynamodb:Scan
169175
- dynamodb:Query
170176
- dynamodb:DescribeTable
171177
- dynamodb:BatchWriteItem
@@ -177,8 +183,14 @@ Resources:
177183
Resource:
178184
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-cache
179185
Condition:
180-
"StringLike":
181-
"dynamodb:LeadingKeys": "entra_*"
186+
ForAllValues:StringEquals:
187+
dynamodb:LeadingKeys:
188+
- entra_id_access_token # add any keys that must be accessible
189+
ForAllValues:StringLike:
190+
dynamodb:Attributes:
191+
- primaryKey
192+
- expireAt
193+
- "*"
182194

183195
# SQS Lambda IAM Role
184196
SqsLambdaIAMRole:

src/api/functions/sts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { duration } from "moment";
66

77
export async function getRoleCredentials(
88
roleArn: string,
9-
durationSeconds: number = 60,
9+
durationSeconds: number = 900,
1010
) {
1111
const client = new STSClient({ region: genericConfig.AwsRegion });
1212
const command = new AssumeRoleCommand({

0 commit comments

Comments
 (0)