fix(aws): allow template-only Auto Scaling group creates
A CreateAutoScalingGroup that names only a launch template sends no autoscaling:InstanceTypes (verified live), so the scaling file's Null:false on it denied every per-user group. Drop it; the type is held by the caller's own ec2:RunInstances launch check on the template, which also refuses MixedInstancesPolicy overrides of unsupported types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9e1a63cde5
commit
bf5a810e0d
4 files changed
+15
-18
No files matched your search
@@ -288,7 +288,6 @@ const GROUP_CREATE: Context = &[
|
||||
"autoscaling:LaunchTemplateVersionSpecified",
|
||||
Literal("true"),
|
||||
),
|
||||
("autoscaling:InstanceTypes", Literal("m7i.large")),
|
||||
];
|
||||
const GROUP_UPDATE: Context = &[
|
||||
(COMPONENT_RESOURCE_TAG, Literal("user-onboarding")),
|
||||
@@ -2816,15 +2815,17 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
// Creating always names the template version and its types; an
|
||||
// update may leave the template alone (a size change, the drain
|
||||
// before destroy).
|
||||
assert!(!allowed(
|
||||
// Creating always names the template version; an update may leave
|
||||
// the template alone (a size change, the drain before destroy).
|
||||
// A template-only create sends no `autoscaling:InstanceTypes`
|
||||
// (verified live, phase 7): it must pass, and the type is held by
|
||||
// the caller's own `ec2:RunInstances` launch check instead.
|
||||
assert!(allowed(
|
||||
tier,
|
||||
&write(
|
||||
"autoscaling:CreateAutoScalingGroup",
|
||||
PROBE_AUTO_SCALING_GROUP,
|
||||
without(GROUP_CREATE, "autoscaling:InstanceTypes")
|
||||
GROUP_CREATE
|
||||
),
|
||||
ME,
|
||||
ME
|
||||
|
||||
@@ -1789,7 +1789,6 @@ const GROUP_CREATE: Context = &[
|
||||
"autoscaling:LaunchTemplateVersionSpecified",
|
||||
Literal("true"),
|
||||
),
|
||||
("autoscaling:InstanceTypes", Literal("m7i.large")),
|
||||
];
|
||||
const GROUP_UPDATE: Context = &[
|
||||
(RESOURCE_COMPONENT, Literal("user-onboarding")),
|
||||
|
||||
+7
-9
@@ -237,7 +237,7 @@ the proof; an action it shows missing is added to the table, the policy, the che
|
||||
| `aws_ecs_capacity_provider` | `ecs:CreateCapacityProvider`, `TagResource` (at create), `ListTagsForResource`, `UpdateCapacityProvider`, `UntagResource`, `DeleteCapacityProvider` (`capacity-provider/triple-c-*--u-*`), `DescribeCapacityProviders` (`*`); `iam:CreateServiceLinkedRole` for `ecs.amazonaws.com` (managed scaling runs as ECS's service-linked role) |
|
||||
| `aws_ecs_cluster_capacity_providers` (the user's) | `ecs:PutClusterCapacityProviders` (the cluster and, expected, the capacity provider) |
|
||||
| `aws_launch_template` | `ec2:CreateLaunchTemplate` (request tag), `CreateTags` (at create), `CreateLaunchTemplateVersion`, `CreateTags`/`DeleteTags`, `DeleteLaunchTemplate` (tagged), `Describe*`. Never `ModifyLaunchTemplate`: the default version never moves (the module must not set `update_default_version` or `default_version`) |
|
||||
| `aws_autoscaling_group` | `autoscaling:CreateAutoScalingGroup` (`triple-c-*--u-*`, request tag, `autoscaling:LaunchTemplateVersionSpecified = true`, no `TargetGroupARNs`/`LoadBalancerNames`, `autoscaling:InstanceTypes` present and supported), `UpdateAutoScalingGroup` (tagged; the same, except that an update which leaves the template alone passes the version check), `SetInstanceProtection`, `CreateOrUpdateTags`/`DeleteTags`, `DeleteAutoScalingGroup` (tagged), `Describe*` (`*`); `iam:CreateServiceLinkedRole` for `autoscaling.amazonaws.com`. Creating a group checks that the caller could launch its template: `ec2:RunInstances` on the tagged launch template; on the instance and its volume only with the component request tag, `ec2:LaunchTemplate` set and (instance) a supported `ec2:InstanceType` (required: a launch whose type IAM doesn't see is denied); on the network interface and subnet with `ec2:LaunchTemplate`; on the security group only the template's own (`ec2:IsLaunchTemplateResource`) component-tagged group; on images only Amazon's, named by the template; `ec2:CreateTags` at `RunInstances`; `iam:PassRole` of the instance role to `ec2.amazonaws.com`. ASG tags are **not** the provider's `default_tags`: the module must set the component tag on the group itself |
|
||||
| `aws_autoscaling_group` | `autoscaling:CreateAutoScalingGroup` (`triple-c-*--u-*`, request tag, `autoscaling:LaunchTemplateVersionSpecified = true`, no `TargetGroupARNs`/`LoadBalancerNames`, `autoscaling:InstanceTypes` supported when present — a template-only create sends none, verified live, so the type is held by the launch check below), `UpdateAutoScalingGroup` (tagged; the same, except that an update which leaves the template alone passes the version check), `SetInstanceProtection`, `CreateOrUpdateTags`/`DeleteTags`, `DeleteAutoScalingGroup` (tagged), `Describe*` (`*`); `iam:CreateServiceLinkedRole` for `autoscaling.amazonaws.com`. Creating a group checks that the caller could launch its template: `ec2:RunInstances` on the tagged launch template; on the instance and its volume only with the component request tag, `ec2:LaunchTemplate` set and (instance) a supported `ec2:InstanceType` (required: a launch whose type IAM doesn't see is denied); on the network interface and subnet with `ec2:LaunchTemplate`; on the security group only the template's own (`ec2:IsLaunchTemplateResource`) component-tagged group; on images only Amazon's, named by the template; `ec2:CreateTags` at `RunInstances`; `iam:PassRole` of the instance role to `ec2.amazonaws.com`. ASG tags are **not** the provider's `default_tags`: the module must set the component tag on the group itself |
|
||||
| `aws_iam_role` (instance), `aws_iam_role_policy` | as the other per-user roles (bounded), on `triple-c-<env>-<owner key>-instance`, tagged `triple-c:cluster = triple-c-<env>--u-<user tag>` (`iam:TagRole`) |
|
||||
| `aws_iam_instance_profile` | `iam:CreateInstanceProfile`, `TagInstanceProfile`, `AddRoleToInstanceProfile` (expected to need `iam:PassRole` of the role too), `GetInstanceProfile`, `ListInstanceProfileTags`, `UntagInstanceProfile`, `RemoveRoleFromInstanceProfile`, `DeleteInstanceProfile` (`instance-profile/triple-c-*`) |
|
||||
| `data.aws_ssm_parameter` (AMI) | `ssm:GetParameter`/`GetParameters` on the public `parameter/aws/service/ecs/optimized-ami/*` |
|
||||
@@ -585,14 +585,12 @@ expected, not verified:
|
||||
- **`ec2:IsLaunchTemplateResource`** is expected to be `true` on the image and security group the
|
||||
template names, and `aws:RequestTag` to carry the template's tag specifications for the instance
|
||||
and volume. If the group's launch check doesn't send either, that statement denies the create.
|
||||
- **`autoscaling:InstanceTypes`** is required on a group create (`Null: false`) and checked
|
||||
against the supported list (`ForAllValues`). Expected: Auto Scaling fills it with the launch
|
||||
template's instance type. If it is absent for a template-only create, every create is denied:
|
||||
then drop the `Null` and rely on the `RunInstances` check (instance type required there). On
|
||||
update it is not required (an update that leaves the template alone, such as the drain before
|
||||
destroy, names no type). There is **no condition key for `MixedInstancesPolicy` or
|
||||
`InstanceRequirements`**; their overrides are expected to appear in `autoscaling:InstanceTypes`
|
||||
and in the launch check, which is what keeps them to the list.
|
||||
- ~~**`autoscaling:InstanceTypes`** required on a group create.~~ **Verified live (phase 7):** a
|
||||
template-only create sends **no** `autoscaling:InstanceTypes`, so the `Null: false` denied every
|
||||
group (the first live onboarding failed on it); it is dropped. Creating a group runs the caller's
|
||||
own `ec2:RunInstances` check on the template ("You are not authorized to use launch template"
|
||||
otherwise), so `ec2:InstanceType` holds the type; a `MixedInstancesPolicy` override of an
|
||||
unsupported type is denied by both checks.
|
||||
- **Instance types in templates.** `ec2:CreateLaunchTemplate`/`CreateLaunchTemplateVersion` are
|
||||
not known to support `ec2:InstanceType` (not in the service authorization reference as I know
|
||||
it), so a template may *name* any type; it can only be *launched* (directly or by a group) with a
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
"Null": {
|
||||
"aws:RequestTag/triple-c:component": "false",
|
||||
"autoscaling:TargetGroupARNs": "true",
|
||||
"autoscaling:LoadBalancerNames": "true",
|
||||
"autoscaling:InstanceTypes": "false"
|
||||
"autoscaling:LoadBalancerNames": "true"
|
||||
},
|
||||
"Bool": {
|
||||
"autoscaling:LaunchTemplateVersionSpecified": "true"
|
||||
|
||||
Reference in new issue
Block a user