Skip to content

cfn: the deployer does not apply stack tags to the resources it creates #746

Closed

Description

@scttfrdmn

Found while verifying #730's ec2:ResourceTag/<key> work with a live SDK run.

ManagedCloudformationResourcesCleanupPolicy — a statement inside the bundled
AmazonECS_FullAccess (emulator/iam_managed.go:1044-1056) — allows
ec2:DeleteInternetGateway, ec2:DeleteRoute, ec2:DeleteRouteTable and
ec2:DeleteSecurityGroup where ec2:ResourceTag/aws:cloudformation:stack-name is like
EC2ContainerService-*. After #730, both aws:ResourceTag/<key> and ec2:ResourceTag/<key>
report a resolved EC2 resource's tags, and a policy written against a caller-settable key
evaluates correctly end to end (verified live: a StringLike on ec2:ResourceTag/Stack
allows DeleteSecurityGroup/DeleteRouteTable on a matching resource and denies on a
non-matching one).

But that particular statement still cannot be satisfied, because nothing in substrate ever
produces the tag it names:

  • CreateTags refuses a key beginning with aws: — "Tag keys starting with 'aws:' are
    reserved for internal use" — which matches AWS, so a caller cannot set it.
  • Substrate's CloudFormation deployer never applies aws:cloudformation:stack-name (or
    aws:cloudformation:stack-id / aws:cloudformation:logical-id) to the resources a stack
    creates: grep -rn 'aws:cloudformation:stack-name' emulator/ finds only the managed-policy
    statement and the comment in authz.go that names it.

Real AWS applies all three tags to every stack-managed resource that supports tagging. They
are observable through DescribeTags/Describe* and they are what tag-scoped policies like
the one above are written against, so their absence is a gap a consumer sees.

Acceptance criteria

  • The CFN deployer applies aws:cloudformation:stack-name, aws:cloudformation:stack-id
    and aws:cloudformation:logical-id to the resources it creates, for the resource types
    whose creates substrate can tag, through the same internal path that bypasses the
    caller-facing aws:-prefix refusal.
  • The refusal for a caller-supplied aws:-prefixed key is unchanged.
  • A test deploys a stack, reads a created resource's tags, and asserts the three values
    against the stack's own name and ID.
  • A test shows ManagedCloudformationResourcesCleanupPolicy granting a delete on a
    resource created by a stack named EC2ContainerService-* and denying it on one created
    by a stack with any other name — i.e. the bundled statement becomes satisfiable.
  • docs/services.md drops the caveat iam: the keys the bundled policies condition on have no producer #730 added under "An operation naming one resource
    by ID is decided against that resource".

Activity

  1. added this to the v0.109.0 milestone on Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions