cloud-custodian / cloud-custodian

Rules engine for cloud security, cost optimization, and governance, DSL in yaml for policies to query, filter, and take actions on resources
https://cloudcustodian.io
Apache License 2.0
5.39k stars 1.47k forks source link

GCP: Incorrect path in policy output (account_id is None) #8266

Open tomarv2 opened 1 year ago

tomarv2 commented 1 year ago

Describe the bug

Project Id is showing up as None in the path in the logs output:

poetry run custodian run --dryrun --cache-period=0 -s "gs://demo/executions/{policy_name}/{account_id}/{now:%Y/%m/%d}/{uuid}" enable-subnet-flowlogs.yml

Cloud Provider

Google Cloud (GCP)

Screen Shot 2023-02-12 at 6 55 24 PM
tomarv2 commented 1 year ago

Looks like the value coming in https://github.com/cloud-custodian/cloud-custodian/blob/620d17df550df718f2f3dc6c044be13604025511/c7n/output.py#L483

    def get_output_vars(self):
        data = {
            'account_id': self.ctx.options.account_id,
            'region': self.ctx.options.region,
            'policy_name': self.ctx.policy.name,
            'now': datetime.datetime.utcnow(),
            'uuid': str(uuid.uuid4()),
        }
{'account_id': None, 'region': '', 'policy_name': 'subnet-flowlogs-enable', 'now': datetime.datetime(2023, 2, 13, 3, 16, 44, 398792), 'uuid': '52752f3a-d55e-4fa7-9bef-a1d4b984ac50'}