aws.sqs

Filters

cross-account

Filter SQS queues which have cross account permissions

example

policies:
  - name: sqs-cross-account
    resource: sqs
    filters:
      - type: cross-account
properties:
  actions:
    items:
      type: string
    type: array
  everyone_only:
    type: boolean
  type:
    enum:
    - cross-account
  whitelist:
    items:
      type: string
    type: array
  whitelist_conditions:
    items:
      type: string
    type: array
  whitelist_from: &id001
    additionalProperties: 'False'
    properties:
      expr:
        oneOf:
        - type: integer
        - type: string
      format:
        enum:
        - csv
        - json
        - txt
        - csv2dict
      url:
        type: string
    required:
    - url
    type: object
  whitelist_orgids:
    items:
      type: string
    type: array
  whitelist_orgids_from: *id001
  whitelist_vpc:
    items:
      type: string
    type: array
  whitelist_vpc_from: *id001
  whitelist_vpce:
    items:
      type: string
    type: array
  whitelist_vpce_from: *id001
required:
- type

kms-key

Filter a resource by its associcated kms key and optionally the aliasname of the kms key by using ‘c7n:AliasName’ The KmsMasterId returned for SQS sometimes has the alias name directly in the value.

example
policies:
    - name: sqs-kms-key-filters
      resource: aws.sqs
      filters:
        - or:
          - type: value
            key: KmsMasterKeyId
            value: "^(alias/aws/)"
            op: regex
          - type: kms-key
            key: c7n:AliasName
            value: "^(alias/aws/)"
            op: regex
properties:
  default:
    type: object
  key:
    type: string
  match-resource:
    type: boolean
  op:
    enum:
    - eq
    - equal
    - ne
    - not-equal
    - gt
    - greater-than
    - ge
    - gte
    - le
    - lte
    - lt
    - less-than
    - glob
    - regex
    - regex-case
    - in
    - ni
    - not-in
    - contains
    - difference
    - intersect
  operator:
    enum:
    - and
    - or
  type:
    enum:
    - kms-key
  value:
    oneOf:
    - type: array
    - type: string
    - type: boolean
    - type: number
    - type: 'null'
  value_from:
    additionalProperties: 'False'
    properties:
      expr:
        oneOf:
        - type: integer
        - type: string
      format:
        enum:
        - csv
        - json
        - txt
        - csv2dict
      url:
        type: string
    required:
    - url
    type: object
  value_regex:
    type: string
  value_type:
    enum:
    - age
    - integer
    - expiration
    - normalize
    - size
    - cidr
    - cidr_size
    - swap
    - resource_count
    - expr
    - unique_size
    - date
required:
- type

Actions

delete

Action to delete a SQS queue

To prevent unwanted deletion of SQS queues, it is recommended to include a filter

example

policies:
  - name: sqs-delete
    resource: sqs
    filters:
      - KmsMasterKeyId: absent
    actions:
      - type: delete
properties:
  type:
    enum:
    - delete
required:
- type

remove-statements

Action to remove policy statements from SQS

example

policies:
   - name: remove-sqs-cross-account
     resource: sqs
     filters:
       - type: cross-account
     actions:
       - type: remove-statements
         statement_ids: matched
properties:
  statement_ids:
    oneOf:
    - enum:
      - matched
      - '*'
    - items:
        type: string
      type: array
  type:
    enum:
    - remove-statements
required:
- statement_ids
- type

set-encryption

Action to set encryption key on SQS queue

example

policies:
  - name: sqs-set-encrypt
    resource: sqs
    filters:
      - KmsMasterKeyId: absent
    actions:
      - type: set-encryption
        key: "<alias of kms key>"
properties:
  key:
    type: string
  type:
    enum:
    - set-encryption
required:
- key

set-retention-period

Action to set the retention period on an SQS queue (in seconds)

example

policies:
  - name: sqs-reduce-long-retention-period
    resource: sqs
    filters:
      - type: value
        key: MessageRetentionPeriod
        value_type: integer
        value: 345600
        op: ge
    actions:
      - type: set-retention-period
        period: 86400
properties:
  period:
    maximum: 1209600
    minimum: 60
    type: integer
  type:
    enum:
    - set-retention-period
required:
- type