Slide 39
Slide 39 text
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
3. AWS Serverless Application Model (AWS SAM)
package main
import future.keywords
legacy_runtime = [
"python2.7",
"nodejs12.x",
"dotnetcore3.1",
]
deny[msg] {
some id, res in input.Resources
res.Type == "AWS::Serverless::Function"
runtime = res.Properties.Runtime
contains(runtime, legacy_runtime[_])
msg = sprintf("%s: %s runtime not allowed", [id, runtime])
}
Resources:
LambdaFunction:
Type: AWS::Serverless::Function
Properties:
Handler: main.handler
Runtime: python2.7
CodeUri: dist
policy
input
Conftest という CLI ツールを利⽤
Rego でポリシーを記述し、YAML のよう
な構造化データに対するテストを書く
ポリシーに違反するリソースの作成、
更新、削除を⾃動で防ぐことができる
[サポートするデータ形式]
CUE, CycloneDX, Dockerfile, EDN,
Environment files (.env), HCL, HCL2,
HOCON, Ignore files
(.gitignore, .dockerignore), INI, JSON,
Jsonnet, Property files (.properties),
SPDX, TextProto (Protocol Buffers),
TOML, VCL, XML, YAML