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

Samples #4

Merged
merged 2 commits into from
May 10, 2024
Merged
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Resources:
Ref: Name
```

## CloudFormation package with a type for each AWS resource

Here's an example of a file you could write using modules in the `cloudformation.pkl` package:

```pkl
Expand Down Expand Up @@ -78,11 +80,15 @@ amends "pkl:Project"

dependencies {
["cfn"] {
uri = "package://github.com/aws-cloudformation/cloudformation-pkl/releases/download/v1.8.3/cloudformation@1.8.3"
uri = "package://github.com/aws-cloudformation/cloudformation-pkl/releases/download/[email protected]/cloudformation@0.1.1
}
}
```

In the directory where you create `PklProject`, run `pkl project resolve`, which will auto-generate the `PklProject.deps.json` file. Then you can run `pkl eval my-template.pkl -f yaml` and the `@cfn` package will be downloaded in order to generate the output.

## Patterns

It's possible to build higher level patterns in Pkl. In the following example,
we are building a VPC defined in `patterns/vpc.pkl`.

Expand Down
8 changes: 8 additions & 0 deletions samples/PklProject
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
amends "pkl:Project"

dependencies {
["cfn"] {
uri = "package://github.com/aws-cloudformation/cloudformation-pkl/releases/download/[email protected]/[email protected]"
}
}

12 changes: 12 additions & 0 deletions samples/PklProject.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://github.com/aws-cloudformation/cloudformation-pkl/releases/download/[email protected]/cloudformation@0": {
"type": "remote",
"uri": "projectpackage://github.com/aws-cloudformation/cloudformation-pkl/releases/download/[email protected]/[email protected]",
"checksums": {
"sha256": "e0d0e916067b40dcc2f335dbb850f3b34e1d93a632c9c01ba3d86f5c361bfeea"
}
}
}
}
22 changes: 22 additions & 0 deletions samples/simple-bucket.pkl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
amends "@cfn/template.pkl"
import "@cfn/cloudformation.pkl" as cfn
import "@cfn/aws/s3/bucket.pkl" as bucket

Description = "Create a bucket"

Metadata {
["Foo"] = "bar"
}

Parameters {
["Name"] {
Type = "String"
Default = "baz"
}
}

Resources {
["TypedBucket"] = new bucket.Bucket {
BucketName = cfn.Ref("Name")
}
}