Skip to content

Added queue delay property to template #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.idea
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ServerlessApiGWSqsPlugin {
deleteStack() {
this.setCloudFormation()
var stackName = this.getStackName(this.options.stage, this.serverless.service.service)

this.cloudformation.deleteStack({StackName: stackName}, function (err, data) {
if (err) {
this.serverless.cli.log("[CodeRecipe ApiGW SQS Plugin] Error: ", err.message);
Expand All @@ -60,12 +60,15 @@ class ServerlessApiGWSqsPlugin {
var stackName = this.getStackName(this.options.stage, this.serverless.service.service)
var apiEndpoint = this.serverless.service.custom.apiGwSqs.apiEndpoint
var queueName = this.serverless.service.custom.apiGwSqs.queueName
var queueDelay = this.serverless.service.custom.apiGwSqs.queueDelay
var replaceStageName = new RegExp('STAGE_NAME', 'g');
var replaceApiEndpoint = new RegExp('API_ENDPOINT', 'g');
var replaceQueueName = new RegExp('QUEUE_NAME', 'g');
var replaceQueueDelay = new RegExp('QUEUE_DELAY', 'g');
contents = contents.replace(replaceStageName, this.options.stage);
contents = contents.replace(replaceApiEndpoint, apiEndpoint);
contents = contents.replace(replaceQueueName, queueName);
contents = contents.replace(replaceQueueDelay, queueDelay);
var params = {
Capabilities: [
'CAPABILITY_IAM'
Expand All @@ -91,7 +94,7 @@ class ServerlessApiGWSqsPlugin {
this.cloudformation.waitFor('stackCreateComplete', {StackName: stackName}, (err, data) => {
if (err) {
console.log(err.message);
}
}
else {
this.serverless.cli.log("[CodeRecipe ApiGW SQS Plugin] Updated ApiGW -> SQS")
}
Expand All @@ -109,7 +112,7 @@ class ServerlessApiGWSqsPlugin {
this.cloudformation.waitFor('stackCreateComplete', {StackName: stackName}, (err, data) => {
if (err) {
console.log(err.message);
}
}
else {
this.serverless.cli.log("[CodeRecipe ApiGW SQS Plugin] Created Api GW -> SQS")
}
Expand All @@ -122,4 +125,4 @@ class ServerlessApiGWSqsPlugin {
}
}

module.exports = ServerlessApiGWSqsPlugin;
module.exports = ServerlessApiGWSqsPlugin;
9 changes: 5 additions & 4 deletions template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Resources:
Type: "AWS::SQS::Queue"
Properties:
QueueName: STAGE_NAME-QUEUE_NAME
DelaySeconds : QUEUE_DELAY

ProxyApi:
Type: AWS::ApiGateway::RestApi
Expand Down Expand Up @@ -53,10 +54,10 @@ Resources:
"application/json": ""
Uri: !Sub arn:aws:apigateway:us-east-1:sqs:path/${AWS::AccountId}/${SQSQueue.QueueName}

APIGatewayDeployment:
APIGatewayDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn: SQSAPIMethod
Properties:
Properties:
RestApiId: !Sub "${ProxyApi}"
StageName: STAGE_NAME

Expand All @@ -72,7 +73,7 @@ Resources:
- apigateway.amazonaws.com
Action: sts:AssumeRole
Policies:
-
-
PolicyName: STAGE_NAME-QUEUE_NAME-policy
PolicyDocument:
Version: '2012-10-17'
Expand All @@ -91,4 +92,4 @@ Resources:

Outputs:
ApiGwUrl:
Value: !Sub "https://${ProxyApi}.execute-api.${AWS::Region}.amazonaws.com/STAGE_NAME/API_ENDPOINT"
Value: !Sub "https://${ProxyApi}.execute-api.${AWS::Region}.amazonaws.com/STAGE_NAME/API_ENDPOINT"