Skip to content
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

Add docs for different string include method #158

Merged
merged 1 commit into from Jul 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/template-files.md
Expand Up @@ -151,6 +151,26 @@ Resources:
Runtime: "python3.7"
```

Sometimes including it directly leads to issues with characters yaml wants to interpret, so another way to include code is through the pipe string handling in yaml:

```yaml
Resources:
LambdaTestFunction:
Type: "AWS::Lambda::Function"
Properties:
Handler: "index.handler"
Role:
Fn::GetAtt:
- "LambdaExecutionRole"
- "Arn"
Code:
Zipfile: |
{{ code('code.py') | indent (10)}}
Runtime: "python3.7"
```

Indention is important here as otherwise whitespace will be added to the file making the string handling problematic.

By default 'code' escapes newlines and apostrophes by using the `code_escape` function defined below. Use the `file` function if you don't want to escape the content.

```python
Expand Down