stelligent / cfn_nag

Linting tool for CloudFormation templates
MIT License
1.26k stars 212 forks source link

unable run custom rule: `audit_impl': undefined method `[]' for nil:NilClass (NoMethodError) #537

Open prat23k opened 3 years ago

prat23k commented 3 years ago

Hi,

I am trying to execute following custom rule getting below error

class S3bucketlogsshouldbeshippedtoMainBucketaccountRule < BaseRule def rule_text ' Access logs from the S3 bucket should be shipped to Main Bucket account please provide DestinationBucketName,LogFilePrefix' end

def rule_type Violation::WARNING end

def rule_id 'CUSTOM11' end

def audit_impl(cfn_model)

resources=  cfn_model.raw_model['Resources']

 destinationbucketName = resources[resources.keys[0]]['Properties']['xxx']['xxx']
  destinationbucketName.empty?
 logFileprefix = resources[resources.keys[0]]['xx']['xxx']['xx']
  logFileprefix.empty?

end end

not only for this rule where ever I used raw model having this issue