Skip to content

[ec2-controller] Expose RunInstancesInput.TagSpecifications in Instance CR spec to support tag-based SCP enforcement #2954

Description

@blackdog0403

Describe the feature

The EC2 controller's generator.yaml currently sets RunInstancesInput.TagSpecifications to ignore (ref: generator.yaml#L110). This prevents users from specifying TagSpecifications in the Instance CR, meaning tags cannot be applied to sub-resources (e.g., EBS volumes, network interfaces) at instance launch time.

Why is this needed?

Many organizations enforce tag-based Service Control Policies (SCPs) via AWS Organizations that require specific tags to be present at resource creation time using aws:RequestTag conditions. For example:

{
  "Effect": "Deny",
  "Action": "ec2:RunInstances",
  "Resource": "arn:aws:ec2:*:*:volume/*",
  "Condition": {
    "Null": {
      "aws:RequestTag/kubernetes.io/created-for/pvc/name": "true"
    }
  }
}

Since ACK does not include TagSpecifications in the RunInstances API call, the SCP denies the operation with:

UnauthorizedOperation: ec2:RunInstances on resource: volume/* with an explicit deny in a service control policy

Post-creation tagging via CreateTags does NOT satisfy SCP conditions, because SCP evaluates aws:RequestTag only at resource creation time.

Proposed Solution

Remove the ignore directive on RunInstancesInput.TagSpecifications in generator.yaml and expose it as a field in the Instance CR spec. This would allow users to pass TagSpecifications at instance launch time, enabling:

  • Tag-based SCP compliance for EBS volumes, ENIs, etc. created with the instance
  • Cost allocation tags applied at creation
  • Compliance with organizational tagging policies

Environment

  • EC2 Controller Version: v1.15.0
  • Kubernetes Version: 1.28+

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    service/ec2Indicates issues or PRs that are related to ec2-controller.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions