-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from aws-samples/dev
feat: sync from dev to main branch
- Loading branch information
Showing
86 changed files
with
5,524 additions
and
2,244 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Duration, StackProps } from 'aws-cdk-lib'; | ||
import * as iam from 'aws-cdk-lib/aws-iam'; | ||
import * as sqs from 'aws-cdk-lib/aws-sqs'; | ||
import { Construct } from 'constructs'; | ||
|
||
|
||
export class ApiQueueStack extends Construct { | ||
|
||
public readonly sqsStatement: iam.PolicyStatement; | ||
public readonly messageQueue: sqs.Queue; | ||
public readonly dlq: sqs.Queue; | ||
|
||
constructor(scope: Construct, id: string) { | ||
super(scope, id); | ||
|
||
const dlq = new sqs.Queue(this, 'LLMApiDLQ', { | ||
encryption: sqs.QueueEncryption.KMS_MANAGED, | ||
retentionPeriod: Duration.days(14), | ||
visibilityTimeout: Duration.hours(10), | ||
}); | ||
|
||
const messageQueue = new sqs.Queue(this, 'LLMApiQueue', { | ||
encryption: sqs.QueueEncryption.KMS_MANAGED, | ||
visibilityTimeout: Duration.hours(3), | ||
deadLetterQueue: { | ||
queue: dlq, | ||
maxReceiveCount: 50, | ||
}, | ||
}); | ||
messageQueue.addToResourcePolicy( | ||
new iam.PolicyStatement({ | ||
effect: iam.Effect.DENY, | ||
principals: [new iam.AnyPrincipal()], | ||
actions: ["sqs:*"], | ||
resources: ["*"], | ||
conditions: { | ||
Bool: { "aws:SecureTransport": "false" } | ||
} | ||
}) | ||
); | ||
|
||
const sqsStatement = new iam.PolicyStatement({ | ||
effect: iam.Effect.ALLOW, | ||
resources: [messageQueue.queueArn], | ||
actions: [ | ||
"sqs:DeleteMessage", | ||
"sqs:GetQueueUrl", | ||
"sqs:ChangeMessageVisibility", | ||
"sqs:PurgeQueue", | ||
"sqs:ReceiveMessage", | ||
"sqs:SendMessage", | ||
"sqs:GetQueueAttributes", | ||
"sqs:SetQueueAttributes", | ||
], | ||
}); | ||
|
||
this.sqsStatement = sqsStatement; | ||
this.messageQueue = messageQueue; | ||
this.dlq = dlq; | ||
} | ||
} |
Oops, something went wrong.