# AWS CloudFormation cfn-guard is now GA - an intro with policy-as-code

**URL:** <https://awshq.com/t/aws-cloudformation-cfn-guard-is-now-ga-an-intro-with-policy-as-code/11944>\
**Category:** Security & IAM\
**Tags:** cloudformation, waf, appsync\
**Created:** [November 16, 2020, 9:37pm UTC](https://awshq.com/t/aws-cloudformation-cfn-guard-is-now-ga-an-intro-with-policy-as-code/11944 "2020-11-16T21:37:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![talkncloud\_mick](https://awshq.com/letter_avatar_proxy/v4/letter/t/9fc29f/32.png) [@talkncloud\_mick](https://awshq.com/u/talkncloud_mick)\
**Post date:** [November 16, 2020, 9:37pm UTC](https://awshq.com/t/aws-cloudformation-cfn-guard-is-now-ga-an-intro-with-policy-as-code/11944/1 "2020-11-16T21:37:17Z")

</div>

Hi All,

Cloudformation is way to define your infrastructure as code (IaC) and last month AWS released cfn-guard which is a command line tool to check your cloudformation templates against certain rules.

It’s a pretty cool little utility, you can generate rules from previous templates and there are examples to get you started.

I walk through one of my previous CDK projects (AppSync WAF) and generate rules based on the template generated from the synth. I then update the rules and the project to modify the firewall rules and the type of authentication used with AppSync. This tests cfn-guard by checking template against my policy and find that the firewall and appsync are not compliant.

Some other stand outs:

- Compatible with CI/CD
- Error 0, 2 codes with overrides
- Firewall like syntax

I’ve written an article here if you want to check out the full write up:

[https://www.talkncloud.com/cloudformation-cfn-guard-policy-as-code/](https://www.talkncloud.com/cloudformation-cfn-guard-policy-as-code/)

You can access my repo here for this project here:

[https://github.com/talkncloud/aws/tree/main/appsync-waf-guard](https://github.com/talkncloud/aws/tree/main/appsync-waf-guard)

You can access cloudformation guard on github here:

[https://github.com/aws-cloudformation/cloudformation-guard](https://github.com/aws-cloudformation/cloudformation-guard)

Keen to hear what others think of this and if you’ve already started using cfn-guard.

Cheers,

Mick.

* * *

**Related discussions:**

- [AWS Cognito with React Native (sample app)](https://awshq.com/t/aws-cognito-with-react-native-sample-app/8748)
- [What feature would you most like to see added to AWS?](https://awshq.com/t/what-feature-would-you-most-like-to-see-added-to-aws/19505)
- [AppSync and Node Microservices](https://awshq.com/t/appsync-and-node-microservices/11068)
- [CloudFront flat-rate plan via CloudFormation?](https://awshq.com/t/cloudfront-flat-rate-plan-via-cloudformation/21325)
- [AppSync API/GraphQL via the PHP SDK?](https://awshq.com/t/appsync-api-graphql-via-the-php-sdk/16748)

---

<div class="post-metadata">

**Author:** ![vennemp](https://awshq.com/letter_avatar_proxy/v4/letter/v/13edae/32.png) [@vennemp](https://awshq.com/u/vennemp)\
**Post date:** [November 16, 2020, 10:08pm UTC](https://awshq.com/t/aws-cloudformation-cfn-guard-is-now-ga-an-intro-with-policy-as-code/11944/2 "2020-11-16T22:08:01Z")

</div>

Been using it in beta for CICD IaC pipeline for customer in govcloud for a couple months. Really useful needs a little ironing out but extremely powerful.

Well done guys!

---

<div class="post-metadata">

**Author:** ![SnooRevelations2232](https://awshq.com/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@SnooRevelations2232](https://awshq.com/u/SnooRevelations2232)\
**Post date:** [November 16, 2020, 11:17pm UTC](https://awshq.com/t/aws-cloudformation-cfn-guard-is-now-ga-an-intro-with-policy-as-code/11944/3 "2020-11-16T23:17:37Z")

</div>

Awesome, but why is this written in Rust when every other AWS CLI tool is Python?

---

<div class="post-metadata">

**Author:** ![talkncloud\_mick](https://awshq.com/letter_avatar_proxy/v4/letter/t/9fc29f/32.png) [@talkncloud\_mick](https://awshq.com/u/talkncloud_mick)\
**Post date:** [November 16, 2020, 11:37pm UTC](https://awshq.com/t/aws-cloudformation-cfn-guard-is-now-ga-an-intro-with-policy-as-code/11944/4 "2020-11-16T23:37:47Z")

</div>

> [@SnooRevelations2232](#):
>
> Awesome, but why is this written in Rust when every other AWS CLI tool is Python?

Thought it was a strange choice as well, I suspect it’s for efficiency?

---

<div class="post-metadata">

**Author:** ![interactionjackson](https://awshq.com/letter_avatar_proxy/v4/letter/i/dec6dc/32.png) [@interactionjackson](https://awshq.com/u/interactionjackson)\
**Post date:** [November 17, 2020, 12:00am UTC](https://awshq.com/t/aws-cloudformation-cfn-guard-is-now-ga-an-intro-with-policy-as-code/11944/5 "2020-11-17T00:00:09Z")

</div>

great post. thanks for the deep dive

---

<div class="post-metadata">

**Author:** ![cddotdotslash](https://awshq.com/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@cddotdotslash](https://awshq.com/u/cddotdotslash)\
**Post date:** [November 17, 2020, 12:22am UTC](https://awshq.com/t/aws-cloudformation-cfn-guard-is-now-ga-an-intro-with-policy-as-code/11944/6 "2020-11-17T00:22:14Z")

</div>

> [@talkncloud\_mick](#):
>
> Thought it was a strange choice as well, I suspect it’s for efficiency?

Strange - how efficient does it need to be? It’s not a web server processing millions of requests per second. At best it’ll have to do a few hundred policy evaluations in an environment (like CI/CD) where the difference between 10 and 100ms is unnoticeable. Not directing this at you, by the way, just thinking out loud.
