Skip to content

Commit

Permalink
fix(apig): fix enabling api gateway logs (SC-2491) (#12655)
Browse files Browse the repository at this point in the history
* fix(apig): fix enabling api gateway logs

* chore: update comment

* docs: update apig logs docs
  • Loading branch information
eahefnawy committed Jul 1, 2024
1 parent e490624 commit 1adeed3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/providers/aws/guide/serverless.yml.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ provider:
# Log full requests/responses for execution logging (default: true)
fullExecutionData: true

# Optional, whether to write CloudWatch logs for custom resource lambdas as added by the framework
frameworkLambda: true
# Optional, whether to write CloudWatch logs for custom resource lambdas as added by the framework. Default is true.
frameworkLambda: false
```
### S3 buckets
Expand Down
5 changes: 4 additions & 1 deletion lib/plugins/aws/custom-resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ async function addCustomResourceToService(

const { serverless } = awsProvider
const providerConfig = serverless.service.provider

// write custom resource lambda logs by default
const shouldWriteLogs =
providerConfig.logs && providerConfig.logs.frameworkLambda
(providerConfig.logs && providerConfig.logs.frameworkLambda) ?? true

const { Resources } = providerConfig.compiledCloudFormationTemplate
const customResourcesRoleLogicalId =
awsProvider.naming.getCustomResourcesRoleLogicalId()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
'use strict'

/**
* IMPORTANT: This file is cached, so when you test changes made to this file,
* make sure you delete the .serverless directory, and un-memoize the packaging code.
* For more info search for the "utils/ensure-artifact.js" file in the codebase.
*/

const { wait, MAX_AWS_REQUEST_TRY } = require('../utils')
const { getEnvironment, handlerWrapper } = require('../utils')
const {
Expand Down Expand Up @@ -60,8 +66,11 @@ async function create(event, context) {
)
).AttachedPolicies
} catch (error) {
if (error.code === 'NoSuchEntity') {
// Role doesn't exist yet, create;
if (
error.code === 'NoSuchEntity' ||
error.message.includes('cannot be found')
) {
// Role doesn't exist yet, create
await iam.send(
new CreateRoleCommand({
AssumeRolePolicyDocument: JSON.stringify({
Expand Down

0 comments on commit 1adeed3

Please sign in to comment.