Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

feat(cloudformation): update AWS::Pipes::Pipe and AWS::Scheduler::ScheduleGroup in place (#1938)

iot-rocketf37268083023
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3db5a7e7..08587f02 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).
### Added
+- **CloudFormation — `AWS::Pipes::Pipe` and `AWS::Scheduler::ScheduleGroup` update in place** — a pipe keeps its stream position and `CreationTime` when `Description`, `Target`, `RoleArn`, `DesiredState` or `Tags` change, gets `Description` and `Tags` on create and refuses a create-only source change under an explicit `Name`, and a schedule group takes template and stack tag changes while keeping tags added through `TagResource`.
- **CloudFormation — EKS cluster and node group updates** — `AWS::EKS::Cluster` applies `Version`, `Logging`, `ResourcesVpcConfig`, `AccessConfig.AuthenticationMode` and `Tags` in place and `AWS::EKS::Nodegroup` applies `ScalingConfig`, `Labels`, `Taints`, `UpdateConfig`, `LaunchTemplate`, `Version`, `ReleaseVersion` and `Tags`, where every such change used to report `UPDATE_COMPLETE` and was dropped.
- **SES — a sandboxed account sends only to verified or simulator recipients** — SES v2 `PutAccountDetails` with `ProductionAccessEnabled=false` puts the account (per region) in the sandbox, as on AWS, and `GetAccount` reports it with the submitted `Details`. A sandboxed send to a recipient that is neither a verified address or domain identity nor a `@simulator.amazonses.com` address fails with `MessageRejected` "Email address is not verified. The following identities failed the check in region …" for v1 `SendEmail`, `SendRawEmail` and `SendTemplatedEmail` and v2 `SendEmail`; bulk sends reject only the affected entries. Accounts stay in production by default. Reported by @skialpine.
diff --git a/ministack/services/cloudformation/provisioners.py b/ministack/services/cloudformation/provisioners.py
index 76b2e2dd..6d690f0a 100644
--- a/ministack/services/cloudformation/provisioners.py
+++ b/ministack/services/cloudformation/provisioners.py
@@ -627,6 +627,31 @@ def _requires_replacement_cognito_resource_server(old_props, new_props):
return old_props.get("UserPoolId") != new_props.get("UserPoolId")
+# The SourceParameters members of AWS::Pipes::Pipe that are create-only.
+_PIPES_SOURCE_CREATE_ONLY = {
+ "DynamoDBStreamParameters": ("StartingPosition",),
+ "KinesisStreamParameters": ("StartingPosition", "StartingPositionTimestamp"),
+ "ActiveMQBrokerParameters": ("QueueName",),
+ "RabbitMQBrokerParameters": ("QueueName", "VirtualHost"),
+ "ManagedStreamingKafkaParameters": ("TopicName", "StartingPosition", "ConsumerGroupID"),
+ "SelfManagedKafkaParameters": (
+ "TopicName", "StartingPosition", "AdditionalBootstrapServers", "ConsumerGroupID",
+ ),
+}
+
+
+def _requires_replacement_pipes(old_props, new_props):
+ """Whether Source or a create-only SourceParameters member changed."""
+ if old_props.get("Source") != new_props.get("Source"):
+ return True
+ old_params = old_props.get("SourceParameters") or {}
+ new_params = new_props.get("SourceParameters") or {}
+ return any(
+ (old_params.get(group) or {}).get(member) != (new_params.get(group) or {}).get(member)
+ for group, members in _PIPES_SOURCE_CREATE_ONLY.items() for member in members
+ )
+
+
# Resource types that carry a user-supplied physical name AND can require
# replacement. Real CloudFormation refuses an update that would replace a
# custom-named resource (you must rename it first), so MiniStack must fail the
@@ -651,6 +676,10 @@ _CUSTOM_NAME_REPLACEMENT = {
"name": "Identifier",
"requires_replacement": _requires_replacement_cognito_resource_server,
},
+ "AWS::Pipes::Pipe": {
+ "name": "Name",
+ "requires_replacement": _requires_replacement_pipes,
+ },
"AWS::IoT::ThingGroup": {
"name": "ThingGroupName",
"requires_replacement": lambda old, new: old.get("ParentGroupName") != new.get("ParentGroupName"),
@@ -3465,6 +3494,25 @@ def _scheduler_group_create(logical_id, props, stack_name):
return name, {"Arn": arn}
+def _scheduler_group_update(physical_id, old_props, new_props, stack_name, logical_id=None):
+ """Name replaces; Tags is the only in-place property."""
+ import ministack.services.scheduler as _sched
+ name = new_props.get("Name") or _physical_name(
+ stack_name, logical_id or physical_id, max_len=64)
+ group = _sched._schedule_groups.get(physical_id)
+ replaced = _rename_replacement(
+ physical_id, old_props, new_props, stack_name, logical_id,
+ name, physical_id if group else None,
+ _scheduler_group_create, _scheduler_group_delete,
+ )
+ if replaced is not None:
+ return replaced
+ tags = _sched._tags.get(group["Arn"], {})
+ _reconcile_tag_map(tags, old_props, new_props)
+ _sched._tags[group["Arn"]] = tags
+ return physical_id, {"Arn": group["Arn"]}
+
+
def _scheduler_group_delete(physical_id, props):
import ministack.services.scheduler as _sched
# Cascade delete child schedules (matches REST API behavior)
@@ -5611,28 +5659,62 @@ def _lambda_event_invoke_config_delete(physical_id, props):
# --- EventBridge Pipes (minimal: DynamoDB Streams -> SNS) ---
+def _pipes_pipe_fields(props):
+ """The UpdatePipe body for the template's in-place properties."""
+ return {
+ "Description": props.get("Description", ""),
+ "RoleArn": props.get("RoleArn", ""),
+ "Target": props.get("Target", ""),
+ "DesiredState": props.get("DesiredState", "RUNNING"),
+ }
+
+
def _pipes_pipe_create(logical_id, props, stack_name):
name = props.get("Name") or _physical_name(stack_name, logical_id, max_len=64)
- source = props.get("Source", "")
- target = props.get("Target", "")
- role_arn = props.get("RoleArn", "")
- desired_state = props.get("DesiredState", "RUNNING")
-
+ fields = _pipes_pipe_fields(props)
source_params = props.get("SourceParameters", {})
ddb_params = source_params.get("DynamoDBStreamParameters", {}) if isinstance(source_params, dict) else {}
starting_position = ddb_params.get("StartingPosition", "LATEST")
pipe = _pipes.register_pipe(
name=name,
- source=source,
- target=target,
- role_arn=role_arn,
- desired_state=desired_state,
+ source=props.get("Source", ""),
+ target=fields["Target"],
+ role_arn=fields["RoleArn"],
+ desired_state=fields["DesiredState"],
starting_position=starting_position,
+ tags=_tag_map(props.get("Tags")),
+ description=fields["Description"],
)
return name, {"Arn": pipe["Arn"], "Name": name}
+def _pipes_pipe_update(physical_id, old_props, new_props, stack_name, logical_id=None):
+ """Name and the source replace; the rest is in place and keeps the stream position."""
+ name = new_props.get("Name") or _physical_name(
+ stack_name, logical_id or physical_id, max_len=64)
+ replaced = _rename_replacement(
+ physical_id, old_props, new_props, stack_name, logical_id,
+ name, physical_id if physical_id in _pipes._pipes else None,
+ _pipes_pipe_create, _pipes_pipe_delete,
+ )
+ if replaced is not None:
+ return replaced
+ if _requires_replacement("AWS::Pipes::Pipe", old_props, new_props):
+ # Not routed through _delete_predecessor, like the Location tracker:
+ # the generated name is deterministic, so register_pipe overwrites the
+ # predecessor and retaining it is not possible here.
+ return _pipes_pipe_create(logical_id or physical_id, new_props, stack_name)
+ fields = _pipes_pipe_fields(new_props)
+ _pipes.check_same_region(fields["Target"])
+ status, _headers, body = _pipes._update_pipe(physical_id, fields)
+ if status >= 400:
+ raise ValueError(f"AWS::Pipes::Pipe update failed: {body!r}")
+ pipe = _pipes._pipes[physical_id]
+ _reconcile_tag_map(pipe.setdefault("Tags", {}), old_props, new_props)
+ return physical_id, {"Arn": pipe["Arn"], "Name": physical_id}
+
+
def _pipes_pipe_delete(physical_id, props):
_pipes.delete_pipe(physical_id)
@@ -12587,6 +12669,7 @@ _REPLACING_PROPERTIES: dict[str, tuple[str, ...]] = {
"AWS::StepFunctions::StateMachine": ("StateMachineName", "StateMachineType"),
"AWS::Cognito::UserPoolGroup": ("GroupName", "UserPoolId"),
"AWS::Cognito::UserPoolResourceServer": ("Identifier", "UserPoolId"),
+ "AWS::Scheduler::ScheduleGroup": ("Name",),
"AWS::IoT::ThingGroup": ("ThingGroupName", "ParentGroupName"),
"AWS::IoT::ThingType": ("ThingTypeName",),
"AWS::Backup::BackupVault": ("BackupVaultName", "EncryptionKeyArn"),
@@ -13012,7 +13095,12 @@ _RESOURCE_HANDLERS = {
"update": _lambda_event_invoke_config_update,
"delete": _lambda_event_invoke_config_delete,
},
- "AWS::Pipes::Pipe": {"create": _pipes_pipe_create, "delete": _pipes_pipe_delete},
+ "AWS::Pipes::Pipe": {
+ "create": _pipes_pipe_create,
+ "update": _pipes_pipe_update,
+ "update_with_logical_id": True,
+ "delete": _pipes_pipe_delete,
+ },
"AWS::Lambda::Alias": {
"create": _lambda_alias_create,
"update": _lambda_alias_update,
@@ -13387,7 +13475,12 @@ _RESOURCE_HANDLERS = {
},
# EventBridge Scheduler
"AWS::Scheduler::Schedule": {"create": _scheduler_schedule_create, "update": _scheduler_schedule_update, "delete": _scheduler_schedule_delete},
- "AWS::Scheduler::ScheduleGroup": {"create": _scheduler_group_create, "delete": _scheduler_group_delete},
+ "AWS::Scheduler::ScheduleGroup": {
+ "create": _scheduler_group_create,
+ "update": _scheduler_group_update,
+ "update_with_logical_id": True,
+ "delete": _scheduler_group_delete,
+ },
# Amazon Location
"AWS::Location::Tracker": {
"create": _location_tracker_create,
diff --git a/ministack/services/pipes.py b/ministack/services/pipes.py
index 918005fb..d5f4eb6e 100644
--- a/ministack/services/pipes.py
+++ b/ministack/services/pipes.py
@@ -136,6 +136,17 @@ def reset():
_positions.clear()
+def check_same_region(*arns):
+ """Raise ValueError when an ARN names a region other than the pipe's."""
+ for component_arn in arns:
+ try:
+ component_region = parse_arn(component_arn).region
+ except ArnParseError:
+ continue
+ if component_region and component_region != get_region():
+ raise ValueError(CROSS_REGION_PIPE_ERROR)
+
+
def register_pipe(
*,
name: str,
@@ -149,13 +160,7 @@ def register_pipe(
):
pipe_region = get_region()
# AWS rejects cross-region source/target ARNs before role validation.
- for component_arn in (source, target):
- try:
- component_region = parse_arn(component_arn).region
- except ArnParseError:
- continue
- if component_region and component_region != pipe_region:
- raise ValueError(CROSS_REGION_PIPE_ERROR)
+ check_same_region(source, target)
arn = f"arn:aws:pipes:{pipe_region}:{get_account_id()}:pipe/{name}"
state = "STOPPED" if str(desired_state).upper() == "STOPPED" else "RUNNING"
diff --git a/tests/test_cfn.py b/tests/test_cfn.py
index 6cee005d..eb13d7df 100644
--- a/tests/test_cfn.py
+++ b/tests/test_cfn.py
@@ -14,7 +14,7 @@ import boto3
import pytest
from botocore.config import Config
from botocore.exceptions import ClientError
-from conftest import iot_test_ca, sqs_policy_allow_s3
+from conftest import iot_test_ca, make_client, sqs_policy_allow_s3
from ministack.services import pipes as _pipes
from ministack.services.cloudformation.provisioners import (
@@ -8121,6 +8121,146 @@ def test_cfn_pipes_rejects_cross_region_target(cfn):
pass
+def _cfn_pipe_template(uid, description, team, desired_state="RUNNING",
+ starting_position="TRIM_HORIZON", target=None,
+ role_arn="arn:aws:iam::000000000000:role/test-pipe-role"):
+ """A DynamoDB stream -> SNS -> SQS pipe; every name is ``cfn-pipe-upd-{uid}``."""
+ name = f"cfn-pipe-upd-{uid}"
+ return json.dumps({"Resources": {
+ "Table": {"Type": "AWS::DynamoDB::Table", "Properties": {
+ "TableName": name, "BillingMode": "PAY_PER_REQUEST",
+ "AttributeDefinitions": [{"AttributeName": "pk", "AttributeType": "S"}],
+ "KeySchema": [{"AttributeName": "pk", "KeyType": "HASH"}],
+ "StreamSpecification": {"StreamViewType": "NEW_IMAGE"}}},
+ "Topic": {"Type": "AWS::SNS::Topic", "Properties": {"TopicName": name}},
+ "Queue": {"Type": "AWS::SQS::Queue", "Properties": {"QueueName": name}},
+ "Sub": {"Type": "AWS::SNS::Subscription", "Properties": {
+ "Protocol": "sqs", "TopicArn": {"Ref": "Topic"},
+ "Endpoint": {"Fn::GetAtt": ["Queue", "Arn"]}}},
+ "Pipe": {"Type": "AWS::Pipes::Pipe", "DependsOn": "Sub", "Properties": {
+ "Name": name,
+ "RoleArn": role_arn,
+ "Source": {"Fn::GetAtt": ["Table", "StreamArn"]},
+ "SourceParameters": {"DynamoDBStreamParameters": {
+ "StartingPosition": starting_position}},
+ "Target": target or {"Ref": "Topic"},
+ "Description": description,
+ "DesiredState": desired_state,
+ "Tags": {"team": team}}},
+ }})
+
+
+def _cfn_pipe_delivered(sqs, queue_url, until):
+ """The pk of every record delivered, read until ``until`` arrived and once more."""
+ pks, deadline, seen = [], time.time() + 10, False
+ while time.time() < deadline:
+ for msg in sqs.receive_message(
+ QueueUrl=queue_url, MaxNumberOfMessages=10, WaitTimeSeconds=1).get("Messages", []):
+ sqs.delete_message(QueueUrl=queue_url, ReceiptHandle=msg["ReceiptHandle"])
+ record = json.loads(json.loads(msg["Body"])["Message"])
+ pks.append(record["dynamodb"]["Keys"]["pk"]["S"])
+ if seen:
+ break
+ seen = until in pks
+ return pks
+
+
+def test_cfn_update_pipe_in_place_keeps_the_stream_position(cfn, ddb, sqs):
+ """Description, Tags, DesiredState, Target and RoleArn change in place and no record is delivered twice."""
+ pipes = make_client("pipes")
+ uid = _uuid_mod.uuid4().hex[:8]
+ name = f"cfn-pipe-upd-{uid}"
+ cfn.create_stack(StackName=name, TemplateBody=_cfn_pipe_template(uid, "v1", "a"))
+ try:
+ stack = _wait_stack(cfn, name)
+ assert stack["StackStatus"] == "CREATE_COMPLETE", stack.get("StackStatusReason")
+ first = pipes.describe_pipe(Name=name)
+ queue_url = sqs.get_queue_url(QueueName=name)["QueueUrl"]
+ ddb.put_item(TableName=name, Item={"pk": {"S": "1"}})
+ assert _cfn_pipe_delivered(sqs, queue_url, "1") == ["1"]
+
+ cfn.update_stack(StackName=name, TemplateBody=_cfn_pipe_template(uid, "v2", "a"))
+ stack = _wait_stack(cfn, name)
+ assert stack["StackStatus"] == "UPDATE_COMPLETE", stack.get("StackStatusReason")
+ ddb.put_item(TableName=name, Item={"pk": {"S": "2"}})
+ assert _cfn_pipe_delivered(sqs, queue_url, "2") == ["2"]
+ pipe = pipes.describe_pipe(Name=name)
+ assert pipe["CreationTime"] == first["CreationTime"]
+ assert (first["Description"], first["Tags"]) == ("v1", {"team": "a"})
+ assert pipe["Description"] == "v2"
+
+ cfn.update_stack(StackName=name, TemplateBody=_cfn_pipe_template(uid, "v2", "b"))
+ assert _wait_stack(cfn, name)["StackStatus"] == "UPDATE_COMPLETE"
+ assert pipes.describe_pipe(Name=name)["Tags"] == {"team": "b"}
+
+ target = first["Target"] + "-other"
+ role_arn = "arn:aws:iam::000000000000:role/test-pipe-role-other"
+ cfn.update_stack(StackName=name, TemplateBody=_cfn_pipe_template(
+ uid, "v2", "b", desired_state="STOPPED", target=target, role_arn=role_arn))
+ assert _wait_stack(cfn, name)["StackStatus"] == "UPDATE_COMPLETE"
+ pipe = pipes.describe_pipe(Name=name)
+ assert (pipe["DesiredState"], pipe["CurrentState"]) == ("STOPPED", "STOPPED")
+ assert (pipe["Target"], pipe["RoleArn"]) == (target, role_arn)
+ assert pipe["CreationTime"] == first["CreationTime"]
+ finally:
+ _delete_cfn_test_stack(cfn, name)
+
+
+def test_cfn_update_pipe_rollback_restores_the_description(cfn):
+ """A pipe changed in place gets its previous Description back when a later resource fails."""
+ pipes = make_client("pipes")
+ uid = _uuid_mod.uuid4().hex[:8]
+ name = f"cfn-pipe-upd-{uid}"
+ cfn.create_stack(StackName=name, TemplateBody=_cfn_pipe_template(uid, "v1", "a"))
+ try:
+ assert _wait_stack(cfn, name)["StackStatus"] == "CREATE_COMPLETE"
+ created = pipes.describe_pipe(Name=name)["CreationTime"]
+ cfn.update_stack(StackName=name, TemplateBody=_cfn_with_failing_resource(
+ _cfn_pipe_template(uid, "v2", "a"), "Pipe"))
+ stack = _wait_stack(cfn, name)
+ assert stack["StackStatus"] == "UPDATE_ROLLBACK_COMPLETE", stack.get("StackStatusReason")
+ pipe = pipes.describe_pipe(Name=name)
+ assert pipe["CreationTime"] == created
+ assert pipe["Description"] == "v1"
+ finally:
+ _delete_cfn_test_stack(cfn, name)
+
+
+def test_cfn_update_pipe_starting_position_on_a_custom_name_is_refused(cfn):
+ """StartingPosition is create-only: under an explicit Name the update is refused."""
+ uid = _uuid_mod.uuid4().hex[:8]
+ name = f"cfn-pipe-upd-{uid}"
+ cfn.create_stack(StackName=name, TemplateBody=_cfn_pipe_template(uid, "v1", "a"))
+ try:
+ assert _wait_stack(cfn, name)["StackStatus"] == "CREATE_COMPLETE"
+ cfn.update_stack(StackName=name, TemplateBody=_cfn_pipe_template(
+ uid, "v1", "a", starting_position="LATEST"))
+ stack = _wait_stack(cfn, name)
+ assert stack["StackStatus"] == "UPDATE_ROLLBACK_COMPLETE", stack.get("StackStatusReason")
+ assert "custom-named resource requires replacing" in _stack_event_reasons(cfn, name)
+ finally:
+ _delete_cfn_test_stack(cfn, name)
+
+
+def test_cfn_update_pipe_cross_region_target_is_refused(cfn):
+ """An in-place Target change to another region's ARN is refused like the create."""
+ pipes = make_client("pipes")
+ uid = _uuid_mod.uuid4().hex[:8]
+ name = f"cfn-pipe-upd-{uid}"
+ cfn.create_stack(StackName=name, TemplateBody=_cfn_pipe_template(uid, "v1", "a"))
+ try:
+ assert _wait_stack(cfn, name)["StackStatus"] == "CREATE_COMPLETE"
+ target = pipes.describe_pipe(Name=name)["Target"]
+ cfn.update_stack(StackName=name, TemplateBody=_cfn_pipe_template(
+ uid, "v1", "a", target=f"arn:aws:sns:us-west-2:000000000000:{name}"))
+ stack = _wait_stack(cfn, name)
+ assert stack["StackStatus"] == "UPDATE_ROLLBACK_COMPLETE", stack.get("StackStatusReason")
+ assert _pipes.CROSS_REGION_PIPE_ERROR in _stack_event_reasons(cfn, name)
+ assert pipes.describe_pipe(Name=name)["Target"] == target
+ finally:
+ _delete_cfn_test_stack(cfn, name)
+
+
def test_cfn_sns_topic_subscription_filter_policy_scope(cfn, sns, sqs):
uid = _uuid_mod.uuid4().hex[:8]
stack_name = f"cfn-sns-filter-{uid}"
@@ -8907,6 +9047,60 @@ def test_cfn_scheduler_schedule(cfn):
assert stack["StackStatus"] == "DELETE_COMPLETE"
+def test_cfn_update_schedule_group_tags_in_place(cfn, scheduler):
+ """A schedule group's template and stack tags change in place and TagResource tags stay."""
+ name = f"cfn-sched-group-{_uuid_mod.uuid4().hex[:8]}"
+
+ def template(team):
+ return json.dumps({
+ "Resources": {"Group": {"Type": "AWS::Scheduler::ScheduleGroup", "Properties": {
+ "Name": name, "Tags": [{"Key": "team", "Value": team}]}}},
+ "Outputs": {"GroupArn": {"Value": {"Fn::GetAtt": ["Group", "Arn"]}}},
+ })
+
+ def group_tags(arn):
+ return {t["Key"]: t["Value"]
+ for t in scheduler.list_tags_for_resource(ResourceArn=arn)["Tags"]}
+
+ cfn.create_stack(StackName=name, TemplateBody=template("a"),
+ Tags=[{"Key": "owner", "Value": "team-a"}])
+ try:
+ stack = _wait_stack(cfn, name)
+ assert stack["StackStatus"] == "CREATE_COMPLETE", stack.get("StackStatusReason")
+ arn = _output(stack, "GroupArn")
+ created = scheduler.get_schedule_group(Name=name)["CreationDate"]
+ scheduler.tag_resource(ResourceArn=arn, Tags=[{"Key": "manual", "Value": "kept"}])
+
+ cfn.update_stack(StackName=name, TemplateBody=template("b"),
+ Tags=[{"Key": "owner", "Value": "team-a"}])
+ stack = _wait_stack(cfn, name)
+ assert stack["StackStatus"] == "UPDATE_COMPLETE", stack.get("StackStatusReason")
+ assert _output(stack, "GroupArn") == arn
+ assert scheduler.get_schedule_group(Name=name)["CreationDate"] == created
+ assert group_tags(arn) == {
+ "team": "b", "manual": "kept", "owner": "team-a", **_system_tags(stack, "Group")}
+
+ cfn.update_stack(StackName=name, UsePreviousTemplate=True,
+ Tags=[{"Key": "owner", "Value": "team-b"}])
+ stack = _wait_stack(cfn, name)
+ assert stack["StackStatus"] == "UPDATE_COMPLETE", stack.get("StackStatusReason")
+ assert group_tags(arn)["owner"] == "team-b"
+ finally:
+ _delete_cfn_test_stack(cfn, name)
+
+
+def test_cfn_schedule_group_change_set_reports_name_as_replacement():
+ """A Name change replaces a schedule group and a Tags change is in place, as its schema says."""
+ rtype = "AWS::Scheduler::ScheduleGroup"
+ renamed = _diff_resources(_template(rtype, {"Name": "a"}), _template(rtype, {"Name": "b"}))
+ retagged = _diff_resources(
+ _template(rtype, {"Name": "a", "Tags": [{"Key": "team", "Value": "a"}]}),
+ _template(rtype, {"Name": "a", "Tags": [{"Key": "team", "Value": "b"}]}))
+ name, tags = renamed[0]["ResourceChange"], retagged[0]["ResourceChange"]
+ assert (_requirements(name), name["Replacement"]) == ({"Name": "Always"}, "True")
+ assert (_requirements(tags), tags["Replacement"]) == ({"Tags": "Never"}, "False")
+
+
def test_cfn_location_tracker(cfn, location):
"""AWS::Location::Tracker provisions through the location service (so it is
readable back through the real API) and the stack tags reach its Tags;
@@ -9587,19 +9781,24 @@ def test_cfn_change_set_keeps_tagged_resources_without_update_handler(cfn, sqs):
_delete_cfn_test_stack(cfn, name)
-def test_cfn_stack_tag_change_keeps_a_resource_without_update_handler(cfn, scheduler):
- """A stack-tag change is an update; a tagged type without an update
- handler (a schedule group) keeps its physical id instead of being
- re-created."""
+def test_cfn_stack_tag_change_keeps_a_resource_without_update_handler(cfn):
+ """A stack-tag change keeps the physical id of a tagged type without an update handler."""
name = f"cfn-tag-only-{_uuid_mod.uuid4().hex[:8]}"
+ app = {"ApplicationId": {"Ref": "App"}}
template = json.dumps({
"Resources": {
- "Group": {
- "Type": "AWS::Scheduler::ScheduleGroup",
- "Properties": {"Name": name},
- },
+ "App": {"Type": "AWS::AppConfig::Application", "Properties": {"Name": name}},
+ "Env": {"Type": "AWS::AppConfig::Environment", "Properties": {**app, "Name": name}},
+ "Profile": {"Type": "AWS::AppConfig::ConfigurationProfile", "Properties": {
+ **app, "Name": name, "LocationUri": "hosted"}},
+ "Strategy": {"Type": "AWS::AppConfig::DeploymentStrategy", "Properties": {
+ "Name": name, "DeploymentDurationInMinutes": 0, "GrowthFactor": 100,
+ "ReplicateTo": "NONE"}},
+ "Deploy": {"Type": "AWS::AppConfig::Deployment", "Properties": {
+ **app, "EnvironmentId": {"Ref": "Env"},
+ "ConfigurationProfileId": {"Ref": "Profile"},
+ "DeploymentStrategyId": {"Ref": "Strategy"}, "ConfigurationVersion": "1"}},
},
- "Outputs": {"GroupArn": {"Value": {"Fn::GetAtt": ["Group", "Arn"]}}},
})
cfn.create_stack(
StackName=name, TemplateBody=template, Tags=[{"Key": "owner", "Value": "team-a"}],
@@ -9607,22 +9806,15 @@ def test_cfn_stack_tag_change_keeps_a_resource_without_update_handler(cfn, sched
try:
stack = _wait_stack(cfn, name)
assert stack["StackStatus"] == "CREATE_COMPLETE", stack.get("StackStatusReason")
- arn = _output(stack, "GroupArn")
cfn.update_stack(
StackName=name, UsePreviousTemplate=True,
Tags=[{"Key": "owner", "Value": "team-b"}],
)
stack = _wait_stack(cfn, name)
assert stack["StackStatus"] == "UPDATE_COMPLETE", stack.get("StackStatusReason")
- assert _output(stack, "GroupArn") == arn
assert stack["Tags"] == [{"Key": "owner", "Value": "team-b"}]
- detail = cfn.describe_stack_resource(StackName=name, LogicalResourceId="Group")
- assert detail["StackResourceDetail"]["PhysicalResourceId"] == name
- # Without an update handler the group keeps the tags it was created
- # with; the changed stack tag does not reach it.
- group_tags = {t["Key"]: t["Value"]
- for t in scheduler.list_tags_for_resource(ResourceArn=arn)["Tags"]}
- assert group_tags == {"owner": "team-a", **_system_tags(stack, "Group")}
+ detail = cfn.describe_stack_resource(StackName=name, LogicalResourceId="Deploy")
+ assert detail["StackResourceDetail"]["PhysicalResourceId"] == "1"
finally:
_delete_cfn_test_stack(cfn, name)