Closed robertstettner closed 4 years ago
Hmm... nothing is immediately jumping out at me here, @robertstettner. The two things that I can suggest are:
policygen
step should write custodian_REGION.yml
files to your current directory, containing the final interpolated policies that are fed into custodian. Perhaps that sheds some light on this problem?manheim-c7n-tools.yml
and also ideally the portion of custodian_us-east-1.yml
for the ec2-auto-tag-user
policy. If you don't feel comfortable posting them here I can provide alternate contact information, but in general (aside from any specifics that you have in your policies) they should be safe to post if you remove the account ID numbers (really, any 12-character string that's all digits).Hi @jantman,
Here is the custodian_us-east-1.yml
file:
policies:
- actions:
- principal_id_tag: CreatorId
tag: Created_by
type: auto-tag-user
filters:
- tag:Created_by: absent
mode:
events:
- RunInstances
type: cloudtrail
name: ec2-auto-tag-user
resource: aws.ec2
- actions:
- tag: Created_by
type: auto-tag-user
- type: set-bucket-encryption
- enabled: true
type: toggle-versioning
- rules:
- Filter:
Prefix: /
ID: company-s3-lifecycle
NoncurrentVersionExpiration:
NoncurrentDays: 35
Status: Enabled
Transitions:
- Days: 180
StorageClass: STANDARD_IA
type: configure-lifecycle
description: 'This policy is triggered when a new S3 bucket is created and it applies
the AWS AES256 Default Bucket Encryption, Tags the creators ID, enables
object versioning, and configures the bucket lifecycle.
'
mode:
events:
- CreateBucket
timeout: 200
type: cloudtrail
name: s3-configure-standards-real-time
resource: aws.s3
And, here is the manheim-c7n-tools.yml
file (anonymised):
- account_name: my-account
account_id: '123456789012'
regions:
- us-east-1
- eu-west-1
- eu-central-1
- us-west-2
assume_role:
role_arn: &dev_role_arn arn:aws:iam::123456789012:role/c7n
output_s3_bucket_name: c7n-123456789012-%%AWS_REGION%%
custodian_log_group: /c7n/%%AWS_REGION%%
dead_letter_queue_arn: &dev_dlq_arn arn:aws:sqs:%%AWS_REGION%%:123456789012:c7n-deadletter-queue
role_arn: *dev_role_arn
mailer_regions:
- eu-west-1
mailer_config:
queue_url: https://sqs.eu-west-1.amazonaws.com/123456789012/c7n-queue
role: *dev_role_arn
from_address: our-team@example.com
region: '%%AWS_REGION%%'
contact_tags:
- OwnerEmail
- ownerEmail
- owneremail
cleanup_notify: []
I have just figured out what the problem was.
I didn't RTFM when it comes to defaults and the policygen
:
Note there is some special handling for the “mode” key: If the mode has a “type” of anything other than “periodic”, it will not be changed at all except by having “tags” updated iff it already has a “tags” key (even if that key has an empty value). As such, modes other than “periodic” must have their full configuration (except tags, which must be present but can be empty) specified in every policy.
Both my policies are using cloudtrail
mode and not periodic
, so that is why my lambdas didn't have a role. I just copy and pasted the defaults into those two policies. and boom. It's working.
Ahhh, ok, yeah. Apologies for that not being more clear... when policygen was originally written, the vast majority of our policies were periodic. I've opened #22 to catch this situation and fail policygen with a helpful error message; I'll try to get that in the next release, whenever that comes.
Apologies for the confusion and poor user experience around this, and I hope you're finding this project helpful.
Hi there,
I have been trying to use your tool, but hit a problem.
I have both the
assume_role
androle_arn
attributes set in themanheim-c7n-tools.yml
config file.The
defaults.yml
file has this set too:I am running this entrypoint using version
0.8.4
:manheim-c7n-runner -S dryrun-diff -S docs dryrun my-account