cloudformation-guard icon indicating copy to clipboard operation
cloudformation-guard copied to clipboard

[Enhancement] Introduce Parameter Inputs for checking the CF scripts

Open konkerama opened this issue 5 years ago • 24 comments

Is your feature request related to a problem? Please describe. In its current form, cfn-guard checks the Cloudformation script without any input.

Example, Lets say I have a Cloudformation script similar to the following (simplified version)

Parameters:
  RDSEncryption:
    Type: String

Resources:
  RDSPostgressDB:
    Type: AWS::RDS::DBInstance
    Properties: 
      StorageEncrypted: !Ref RDSEncryption

I want to create an RDS Database and I have a CF parameter input for encryption (true/false). Currently there is no way in cfn-guard to verify that the RDS will be created using encryption. I can only verify that the StorageEncrypted will have the value "RDSEncryption" (please correct me if I'm wrong)

Describe the solution you'd like I would prefer an option to provide a json document with the CF parameter inputs and be able to check the Cloudformation script after all those values have been implemented. The example I gave above would look like:

rules:

AWS::RDS::DBInstance StorageEncrypted == true

input.json:

[
  {
    "ParameterKey": "RDSEncryption",
    "ParameterValue": "true"
  }
]

cfn-guard:

cargo run -- -t rds.yaml -r rules -i input.json

cfn-guard will change the RDSEncryption Rerefence with the input true and will be able to check against that

konkerama avatar Jul 09 '20 09:07 konkerama

This is a very reasonable use-case. We're kicking this kind of thing around already. Let's use this issue to track the work.

nathanataws avatar Jul 10 '20 19:07 nathanataws

Guys is there any ETA on this feature release?

rajddas avatar Jul 17 '20 09:07 rajddas

No ETA yet but still a high priority.

nathanataws avatar Jul 17 '20 15:07 nathanataws

This raises larger questions of CloudFormation template syntax: dynamic references, intrinsic functions, psuedoparameters, parameters, mappings, conditions, transforms, etc.

PatMyron avatar Sep 17 '20 17:09 PatMyron

@PatMyron indeed supporting all these "dynamic" features of Cloudformation will be necessary for a tool like this. From my point of view, the Input Parameter support has the highest priority of those features and its the bare minimum functionality we require to include it as a compliance mechanism in our CICD Pipelines

konkerama avatar Sep 18 '20 18:09 konkerama

Also it would be great if we allow the parameter json files needed for CodePipeline Cloudformation Action. Like this :

{
    "Parameters" : {
        "Owner": "ABC",
        "CostCenter": "1234567890"
    }
}

rajddas avatar Oct 02 '20 15:10 rajddas

Any update on this feature request?

rajddas avatar Oct 16 '20 08:10 rajddas

Any update on this? Basically we would like CFN-guard to resolve the "Ref" from "Parameters" and allow us to validate the input value. W/o this feature, I don't see major uptake on this. Thanks

n1t1nv3rma avatar Nov 11 '20 05:11 n1t1nv3rma

we use taskcat in CI/CD Pipelines for testing Cloudformation templates, we have written a lot of taskcat files for templates with different test cases like eg enable/disable encryption, encryption with kms/user manged keys. it would be good if we reuse/provide those taskcat files as input to cfn-guard, thanks https://github.com/aws-quickstart/taskcat

shreyasmm avatar Nov 18 '20 07:11 shreyasmm

I also see this feature as essential, both for testing new templates and running validation checks on pre-existing templates.

Parameters are essential in all but the simplest of cloudformation templates, and therefore cloudformation-guard MUST support it to be usable on a large scale.

Perhaps CLI args can be passed in for each parameter, and cfn guard creates a new template with the previously-parameterized values now hardcoded into the template. CFN guard then runs checks on that template?

Where parameters support have default values, CFN guard will default to those values unless overridden? This would reduce the need to specify many parameter values for each test

el-veee avatar Jan 08 '21 04:01 el-veee

is there any update on this please. Eagerly waiting for utilizing it.

sriram9707 avatar May 08 '21 17:05 sriram9707

is this something handled in release 2.0 ?

sriram9707 avatar May 18 '21 03:05 sriram9707

@sriram9707 @lachlan-vass @konkerama Currently this would require re-implementing the entire CFN server-side resolution semantics again in Guard. Would it be okay if we provided a separate binary/library that does CFN resolution semantics given a template and parameter file in JSON/YAML (complete support for intrinsic resolutions, will not have support for Macros/Transforms, however initially) and have that piped to guard. E.g.

cfn-resolve -t template -p parameters.yaml | cfn-guard -r rules 

dchakrav-github avatar May 20 '21 20:05 dchakrav-github

@dchakrav-github

The usage of what you're proposing still looks quite simple. I'm fine with it

el-veee avatar May 21 '21 03:05 el-veee

is there any ETA on this ? @dchakrav-github

sriram9707 avatar Jun 13 '21 07:06 sriram9707

@dchakrav-github @PatMyron any ETA for this ?. we have been trying to leverage cfn guard thorugh our pipeline which will have template and respective parameters file. or is there any workaround for this ?

sriram9707 avatar Sep 03 '21 06:09 sriram9707

We do not have an ETA on this as of today; however, we are discussing internally to determine how best to approach this.

razcloud avatar May 02 '22 22:05 razcloud

Was there any progress on this, or same position as one year ago?

fabiodouek avatar Feb 24 '23 12:02 fabiodouek

Hi @fabiodouek This item is currently in our backlog. We do not have an estimate on when this feature will be delivered.

razcloud avatar Feb 24 '23 15:02 razcloud

Is the above issue resolved on latest Cloud Formation Guard version i.e 2.1.3 as it is basic use case in most of the cfn templates ?

sha-aegon avatar Apr 07 '23 10:04 sha-aegon

@sha-aegon Hi, this is still in our backlog. We do not have an estimate for when this will be implemented/released.

Thanks

joshfried-aws avatar Aug 02 '23 14:08 joshfried-aws