cloudformation-coverage-roadmap icon indicating copy to clipboard operation
cloudformation-coverage-roadmap copied to clipboard

AWS Config Organizational Custom Rules using Guard Custom policy

Open lvthillo opened this issue 3 years ago • 4 comments

Name of the resource

AWS::Config::OrganizationConfigRule

Resource name

No response

Description

We can create an organizational config rule (organization-custom-policy-rule-metadata) using the CLI

$ aws configservice put-organization-config-rule --organization-config-rule-name test-1 --organization-custom-policy-rule-metadata PolicyRuntime="guard-2.x.x",PolicyText="let var=5",OrganizationConfigRuleTriggerTypes=ConfigurationItemChangeNotification

It's also possible with some SDKs like boto3:

response = client.put_organization_config_rule(
    OrganizationConfigRuleName='test-rule-2',
    OrganizationCustomPolicyRuleMetadata={
        'OrganizationConfigRuleTriggerTypes': ['ConfigurationItemChangeNotification'],
        'PolicyRuntime': 'guard-2.x.x',
        'PolicyText': 'let test = 123'
    }
)

Unfortunately it's not supported by CloudFormation.

Other Details

No response

lvthillo avatar Aug 12 '22 11:08 lvthillo

The AWS Service team which owns the AWS::Config::OrganizationConfigRule resource is working on the fix for this issue.

jtobin321 avatar Oct 27 '22 19:10 jtobin321

It would be great if this resource would also accept an s3 URL as an alternative for inlining it in the template. Cloudformation Guard has a built in testing framework and it is inconvenient to have to take the guard files and pass them into the template somehow.

prowe-athene avatar Oct 28 '22 00:10 prowe-athene

It's kind of almost there? When trying to define via a OrganizationCustomCodeRuleMetadata block as per the spec, it throws InvalidParameterException with

Specify either OrganizationCustomRuleMetadata, OrganizationManagedRuleMetadata, or OrganizationCustomPolicyRuleMetadata in the input. (Service: AmazonConfig; Status Code: 400; Error Code: InvalidParameterValueException

So you try OrganizationCustomPolicyRuleMetadata as instructed and it circles back to

Property validation failure: [Encountered unsupported properties in {/}: [OrganizationCustomPolicyRuleMetadata]]

ap-southeast-2

elduds avatar Dec 16 '22 03:12 elduds

@jtobin321 any update? Seems a while ago and I don't see the possibility to create a custom config rule backed by guard in the CF docs.

lvthillo avatar Jun 24 '24 11:06 lvthillo