Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

JamesWoolfenden/terraform-bridgecrew-examples

Repository files navigation

Terraform Bridgecrew Examples

Latest Release GitHub tag (latest SemVer) Terraform Version Infrastructure Tests pre-commit checkov Infrastructure Tests

These early examples show how to use terraform to extract data from the bridgecrew platform, and how to create policies in code.

example_provider/

How to set-up the provider and authentication.

Add your bridgecrew API key as an Environmental variable:

export BRIDGECREW_API="xxxx"

example_data/

Demonstrates the 6 of the current data sources for repositories, policies, suppressions and the newer authors,incidents and justifications.

example_simple_policy/

Demonstrates how to create a basic policy in Terraform.

example_yaml_policy/

Demonstrates how to create a yaml policy in Terraform.

Each Folder has a video walk-through.

example_connected/

This examples shows you how to create a policy and then using it against some IaC. Check a Terraform template against your current policy set, buy running the Make target fail:

make fail

This template would provision an aws_instance of the instance_type t3.medium.

Then we add a new policy that checks that the instance size of the aws_instance resource is "t3.micro", run the Make Target policy:

make policy

Once the policy is deployed you can test it again with previous Make fail target:

make fail 

And you should see (In your Checkov output):

Check: james_aws_1636551748078: "Ensure Developers use the AWS free tier"
        FAILED for resource: aws_instance.non_compliant
        File: /aws_instance.non_compliant.tf:18-27

                18 | resource "aws_instance" "non_compliant" {
                19 |    # checkov:skip=CKV_AWS_79: ADD REASON
                20 |   ami           = data.aws_ami.ubuntu.id
                21 |   instance_type = "t3.medium"
                22 |     root_block_device {
                23 |     encrypted = true
                24 |   }
                25 |   monitoring = true
                26 |   ebs_optimized = true
                27 | }

Finally remove the added check with target destroy:

make destroy

example tag

This example shows how to define a tag rule for the platform.

Requirements

No requirements.

Providers

No providers.

Modules

No modules.

Resources

No resources.

Inputs

No inputs.

Outputs

No outputs.

Help

Got a question?

File a GitHub issue.

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Copyrights

Copyright © 2021-2022 James Woolfenden

License

License

See LICENSE for full details.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributors

James Woolfenden
James Woolfenden