/dhall-aws-cloudformation/gh-pages/package.dhall.html
Copy path to clipboardSource
<!DOCTYPE HTML><html><head><title>/package.dhall</title><link rel="stylesheet" type="text/css" href="index.css"><link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Lato:ital,wght@0,400;0,700;1,400&display=swap"><script type="text/javascript" src="index.js"></script><meta charset="UTF-8"></head><body><div class="nav-bar"><img class="dhall-icon" src="dhall-icon.svg"><p class="package-title">dhall-aws-cloudformation</p><div class="nav-bar-content-divider"></div><a id="switch-light-dark-mode" class="nav-option">Switch Light/Dark Mode</a></div><div class="main-container"><h2 class="doc-title"><span class="crumb-divider">/</span><a href="index.html">dhall-aws-cloudformation</a><span class="crumb-divider">/</span><span class="title-crumb" href="index.html">package.dhall</span></h2><a class="copy-to-clipboard" data-path="https://raw.githubusercontent.com/jcouyang/dhall-aws-cloudformation/0.9.81/package.dhall"><i><small>Copy path to clipboard</small></i></a><br><div class="doc-contents"><p>AWS Cloudformation has massive amount of specifications, to load all
dhall remotely will be very slow and impractical.</p>
<p>One simply way to make import faster is by only importing just each resource you need</p>
<h4 id="remote-import-resource">Remote import resource</h4>
<pre><code class="language-dhall">let AwsLambda = https://github.com/jcouyang/dhall-aws-cloudformation/raw/<version>/cloudformation/AWS::Lambda::Function.dhall
</code></pre>
<p>Other way around is build the binary of subset of the resources using nix</p>
<h4 id="build-and-load-packagedhall-binary-to-local-cache">Build and load package.dhall binary to local cache</h4>
<p>Have something like <code>./examples/example0.nix</code>, and the dhall file you want to compile <code>./examples/example0.dhall</code></p>
<pre><code class="language-nix">let pkgs = import ../default.nix {
cf-preset = [
"AWS::Lambda::Function"
];
};
in pkgs.runCommand "build-dhall-cf-nix-example" {
nativeBuildInputs = [ pkgs.dhall-json ];
src = ./.;
} ''
cp -r ${pkgs.dhallPackages.aws-cloudformation}/.cache/ ./
echo " ⚠ ─ If error occured, you may need to update the sha256 in your dhall file e.g."
echo " │ let aws-cloudformation = $(cat ${pkgs.dhallPackages.aws-cloudformation}/binary.dhall)"
chmod -R u+w .cache
mkdir $out
XDG_CACHE_HOME=.cache dhall-to-yaml --file $src/example0.dhall --output $out/example0.yaml
''
</code></pre>
<p>Add all the resources you need to <code>cf-preset</code>, run nix-build, if the subset is not too large it will be very quick, and you will see something like:</p>
<pre><code> ⚠ ─ If error occured, you may need to update the sha256 in your dhall file e.g.
│ let aws = missing sha256:a04e4db67b092e40987639cca5cd845f452b3984ee7ec77172f815a31e830325
</code></pre>
<p>Actually the first time it will fail since you can't guess the correct sha of the subset binary, now if you update example0.dhall with the correct sha,
it should then be able to compile to <code>./result/example0.yaml</code></p>
<pre><code class="language-dhall">let aws =
missing
sha256:a04e4db67b092e40987639cca5cd845f452b3984ee7ec77172f815a31e830325
let Function = aws.Cloudformation.`AWS::Lambda::Function`
</code></pre>
</div><h3>Source</h3><div class="source-code"><pre>{-|<br>AWS Cloudformation has massive amount of specifications, to load all<br>dhall remotely will be very slow and impractical.<br><br>One simply way to make import faster is by only importing just each resource you need<br>#### Remote import resource<br>```dhall<br>let AwsLambda = https://github.com/jcouyang/dhall-aws-cloudformation/raw/<version>/cloudformation/AWS::Lambda::Function.dhall<br>```<br>Other way around is build the binary of subset of the resources using nix<br>#### Build and load package.dhall binary to local cache<br>Have something like `./examples/example0.nix`, and the dhall file you want to compile `./examples/example0.dhall`<br>```nix<br>let pkgs = import ../default.nix {<br> cf-preset = [<br> "AWS::Lambda::Function"<br> ];<br> };<br>in pkgs.runCommand "build-dhall-cf-nix-example" {<br> nativeBuildInputs = [ pkgs.dhall-json ];<br> src = ./.;<br>} ''<br>cp -r ${pkgs.dhallPackages.aws-cloudformation}/.cache/ ./<br>echo " ⚠ ─ If error occured, you may need to update the sha256 in your dhall file e.g."<br>echo " │ let aws-cloudformation = $(cat ${pkgs.dhallPackages.aws-cloudformation}/binary.dhall)"<br>chmod -R u+w .cache<br>mkdir $out<br>XDG_CACHE_HOME=.cache dhall-to-yaml --file $src/example0.dhall --output $out/example0.yaml<br>''<br>```<br>Add all the resources you need to `cf-preset`, run nix-build, if the subset is not too large it will be very quick, and you will see something like:<br>```<br> ⚠ ─ If error occured, you may need to update the sha256 in your dhall file e.g.<br> │ let aws = missing sha256:a04e4db67b092e40987639cca5cd845f452b3984ee7ec77172f815a31e830325<br>```<br>Actually the first time it will fail since you can't guess the correct sha of the subset binary, now if you update example0.dhall with the correct sha,<br>it should then be able to compile to `./result/example0.yaml`<br>```dhall<br>let aws =<br> missing<br> sha256:a04e4db67b092e40987639cca5cd845f452b3984ee7ec77172f815a31e830325<br><br>let Function = aws.Cloudformation.`AWS::Lambda::Function`<br>```<br>-}<br>{ Cloudformation = <a href="./cloudformation/package.dhall.html">./cloudformation/package.dhall</a><br>, Cloudformation/Version = <a href="./cloudformation/SpecificationVersion.dhall.html">./cloudformation/SpecificationVersion.dhall</a><br>, Sam = <a href="./sam/package.dhall.html">./sam/package.dhall</a><br>, Sam/Policy = <a href="./sam/policy-template/package.dhall.html">./sam/policy-template/package.dhall</a><br>, Sam/Version = <a href="./sam/SpecificationVersion.dhall.html">./sam/SpecificationVersion.dhall</a><br>, Fn = <a href="./Fn.dhall.html">./Fn.dhall</a><br>, Prelude = <a href="./Prelude.dhall.html">./Prelude.dhall</a><br>, CreateionPolicy = <a href="./CreationPolicy.dhall.html">./CreationPolicy.dhall</a><br>, DeletionPolicy = <a href="./DeletionPolicy.dhall.html">./DeletionPolicy.dhall</a><br>, UpdatePolicy = <a href="./UpdatePolicy.dhall.html">./UpdatePolicy.dhall</a><br>}<br></pre></div></div></body></html>