Skip to content

CFN: LaunchTemplate, InstanceProfile, SecurityGroupIngress fall to generic stub despite handlers existing #388

Closed

Description

@scttfrdmn

The gap

The CFN deployer's switch res.Type in emulator/betty_cfn.go has 109 cases and falls back
to deployGenericStub for anything else (with a "unknown CloudFormation resource type"
warning). That fallback is reasonable for services the emulator does not model — but four
resource types fall through to it even though the corresponding API actions are already
implemented and routed
.

CFN resource type CFN deployer API action, already implemented
AWS::EC2::LaunchTemplate generic stub CreateLaunchTemplate (ec2_plugin.go:188), DescribeLaunchTemplates (:190), DeleteLaunchTemplate (:192)
AWS::EC2::SecurityGroupIngress generic stub AuthorizeSecurityGroupIngress (ec2_plugin.go:90)
AWS::IAM::InstanceProfile generic stub CreateInstanceProfile (iam_plugin.go:153), AddRoleToInstanceProfile (:159), GetInstanceProfile (:155)
AWS::EC2::NetworkInterface generic stub — (no CreateNetworkInterface; genuinely absent)

The first three are the interesting ones: the state-mutating handler exists, the wiring
doesn't.

Why it matters

The existing EC2 handlers show the intended pattern — deployEC2Instance dispatches a real
RunInstances (betty_cfn.go:2019), so an instance declared in a template is afterwards
visible to DescribeInstances. deployEC2SecurityGroup likewise dispatches
CreateSecurityGroup (:1934).

When a type falls to the generic stub, it gets a synthesized ARN and stack state but no
emulator-side resource
. So a template that deploys "successfully" leaves you unable to
observe what it created:

  • Deploy a stack with an AWS::EC2::LaunchTemplate, then call DescribeLaunchTemplates → not
    there. The handler that would have created it is one dispatch away.
  • Deploy AWS::IAM::InstanceProfile, then GetInstanceProfile → not there, and an
    AWS::EC2::Instance in the same template referencing it via IamInstanceProfile has nothing
    to resolve to.
  • AWS::EC2::SecurityGroupIngress is a standalone rule resource (the common way to express a
    self-referencing group, since it cannot be inline). deployEC2SecurityGroup also ignores
    inline SecurityGroupIngress properties, so neither route produces ingress rules —
    meaning DescribeSecurityGroups after a stack deploy reports a group with no rules
    regardless of how the template was written.

That last one is the sharpest: a test that asserts "my template opens port 6818 within the
compute security group" passes deploy and then can't verify the rule, in a way that looks like
the assertion is wrong rather than the emulator being silent.

Suggested fix

Add four cases following deployEC2Instance's existing shape — resolve properties, dispatch
the real action, record the physical ID from the response:

  1. AWS::EC2::LaunchTemplate → CreateLaunchTemplate, physical ID from launchTemplateId.
  2. AWS::IAM::InstanceProfile → CreateInstanceProfile + AddRoleToInstanceProfile for each
    entry in Roles.
  3. AWS::EC2::SecurityGroupIngress → AuthorizeSecurityGroupIngress, resolving GroupId /
    SourceSecurityGroupId through the same Ref/GetAtt path other handlers use (a
    self-referencing rule is the main reason this resource type exists standalone).
  4. Optionally have deployEC2SecurityGroup also authorize inline SecurityGroupIngress /
    SecurityGroupEgress properties, so both spellings behave the same.

AWS::EC2::NetworkInterface needs a CreateNetworkInterface handler first, so it is a
larger piece of work and arguably belongs in its own issue.

A cheap general improvement, independent of the above: have deployGenericStub note when the
unhandled type's service plugin is loaded. The current warning reads as "substrate doesn't
model this," which is misleading when the actions exist.

How I found it

Auditing the AWS surface of a Slurm power-save plugin
(scttfrdmn/aws-plugin-for-slurm) against
this emulator; its CloudFormation template declares all four of these. Filed separately from
the CreateFleet gap (#387) because this one is wiring between two layers that both already
exist, not a missing API. Not blocking me.

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