kapilt: Thanks for the pull request!  If you don't mind could you sign the CLA per the developer docs? Direct link here: https://docs.google.com/forms/d/e/1FAIpQLSfwtl1s6KmpLhCY6CjiY8nFZshDwf_wrmNYx1ahpsNFXXmHKw/viewform
kapilt: can you switch the account id here in the recorded output to the one we use in other test data and rebase.
fussybeaver: Thanks for the feedback. Rebased master, removed trailing whitespace and changed account id.
diff --git a/c7n/resources/asg.py b/c7n/resources/asg.py
index 9d01ee426..181141dd9 100644
--- a/c7n/resources/asg.py
+++ b/c7n/resources/asg.py
@@ -1215,7 +1215,7 @@ class PropagateTags(Action):
         if self.data.get('trim', False):
             instances = [self.instance_map[i] for i in instance_ids]
             self.prune_instance_tags(client, asg, tag_set, instances)
-        if not self.manager.config.dryrun:
+        if not self.manager.config.dryrun and instances:
             client.create_tags(
                 Resources=instance_ids,
                 Tags=[{'Key': k, 'Value': v} for k, v in tag_map.items()])

aws:asg propagte-tags action errors on asgs without instances
The error message when I try to use the propagate-tags action is the following:

```
[ERROR] 2019-11-19T02:56:38.336Z b1c8af86-d773-412d-b755-638faf7698e8 Error while executing policy
20:56:38 Traceback (most recent call last):
20:56:38 File "/var/task/c7n/policy.py", line 320, in run
20:56:38 results = a.process(resources)
20:56:38 File "/var/task/c7n/resources/asg.py", line 1200, in process
20:56:38 instance_count = sum(list(w.map(self.process_asg, asgs)))
20:56:38 File "/var/lang/lib/python3.7/concurrent/futures/_base.py", line 598, in result_iterator
20:56:38 yield fs.pop().result()
20:56:38 File "/var/lang/lib/python3.7/concurrent/futures/_base.py", line 435, in result
20:56:38 return self.__get_result()
20:56:38 File "/var/lang/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
20:56:38 raise self._exception
20:56:38 File "/var/lang/lib/python3.7/concurrent/futures/thread.py", line 57, in run
20:56:38 result = self.fn(*self.args, **self.kwargs)
20:56:38 File "/var/task/c7n/resources/asg.py", line 1221, in process_asg
20:56:38 Tags=[{'Key': k, 'Value': v} for k, v in tag_map.items()])
20:56:38 File "/var/runtime/botocore/client.py", line 357, in _api_call
20:56:38 return self._make_api_call(operation_name, kwargs)
20:56:38 File "/var/runtime/botocore/client.py", line 661, in _make_api_call
20:56:38 raise error_class(parsed_response, operation_name)
20:56:38 botocore.exceptions.ClientError: An error occurred (MissingParameter) when calling the CreateTags operation: The request must contain the parameter resourceIdSet
20:56:38 [ERROR] 2019-11-19T02:56:38.338Z b1c8af86-d773-412d-b755-638faf7698e8 error during policy execution
20:56:38 Traceback (most recent call last):
20:56:38 File "/var/task/c7n/handler.py", line 168, in dispatch_event
20:56:38 p.push(event, context)
20:56:38 File "/var/task/c7n/policy.py", line 991, in push
20:56:38 return mode.run(event, lambda_ctx)
20:56:38 File "/var/task/c7n/policy.py", line 591, in run
20:56:38 return PullMode.run(self)
20:56:38 File "/var/task/c7n/policy.py", line 320, in run
20:56:38 results = a.process(resources)
20:56:38 File "/var/task/c7n/resources/asg.py", line 1200, in process
20:56:38 instance_count = sum(list(w.map(self.process_asg, asgs)))
20:56:38 File "/var/lang/lib/python3.7/concurrent/futures/_base.py", line 598, in result_iterator
20:56:38 yield fs.pop().result()
20:56:38 File "/var/lang/lib/python3.7/concurrent/futures/_base.py", line 435, in result
20:56:38 return self.__get_result()
20:56:38 File "/var/lang/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
20:56:38 raise self._exception
20:56:38 File "/var/lang/lib/python3.7/concurrent/futures/thread.py", line 57, in run
20:56:38 result = self.fn(*self.args, **self.kwargs)
20:56:38 File "/var/task/c7n/resources/asg.py", line 1221, in process_asg
20:56:38 Tags=[{'Key': k, 'Value': v} for k, v in tag_map.items()])
20:56:38 File "/var/runtime/botocore/client.py", line 357, in _api_call
20:56:38 return self._make_api_call(operation_name, kwargs)
20:56:38 File "/var/runtime/botocore/client.py", line 661, in _make_api_call
20:56:38 raise error_class(parsed_response, operation_name)
20:56:38 botocore.exceptions.ClientError: An error occurred (MissingParameter) when calling the CreateTags operation: The request must contain the parameter resourceIdSet
20:56:38 [ERROR] ClientError: An error occurred (MissingParameter) when calling the CreateTags operation: The request must contain the parameter resourceIdSet Traceback (most recent call last):   File "/var/task/custodian_policy.py", line 4, in run     return handler.dispatch_event(event, context)   File "/var/task/c7n/handler.py", line 168, in dispatch_event     p.push(event, context)   File "/var/task/c7
20:56:38 END RequestId: b1c8af86-d773-412d-b755-638faf7698e8
```
diff --git a/tests/data/placebo/test_asg_propagate_tag_no_instances/autoscaling.DescribeAutoScalingGroups_1.json b/tests/data/placebo/test_asg_propagate_tag_no_instances/autoscaling.DescribeAutoScalingGroups_1.json
new file mode 100644
index 000000000..3e8368da5
--- /dev/null
+++ b/tests/data/placebo/test_asg_propagate_tag_no_instances/autoscaling.DescribeAutoScalingGroups_1.json
@@ -0,0 +1,64 @@
+{
+    "status_code": 200,
+    "data": {
+        "AutoScalingGroups": [
+            {
+                "AutoScalingGroupARN": "arn:aws:autoscaling:us-east-1:123456789012:autoScalingGroup:5fd42b45-825e-45c1-b02a-6a97d9512f30:autoScalingGroupName/c7n.asg.ec2.01",
+                "TargetGroupARNs": [],
+                "SuspendedProcesses": [],
+                "DesiredCapacity": 1,
+                "Tags": [
+                    {
+                        "ResourceType": "auto-scaling-group",
+                        "ResourceId": "CustodianASG",
+                        "PropagateAtLaunch": true,
+                        "Value": "ubuntu",
+                        "Key": "Platform"
+                    }
+                ],
+                "EnabledMetrics": [],
+                "LoadBalancerNames": [],
+                "AutoScalingGroupName": "c7n.asg.ec2.01",
+                "DefaultCooldown": 300,
+                "MinSize": 1,
+                "Instances": [
+                ],
+                "MaxSize": 1,
+                "VPCZoneIdentifier": "subnet-ea6429a3,subnet-2c5dcf01",
+                "HealthCheckGracePeriod": 300,
+                "TerminationPolicies": [
+                    "Default"
+                ],
+                "LaunchConfigurationName": "c7n.asg.01",
+                "CreatedTime": {
+                    "hour": 19,
+                    "__class__": "datetime",
+                    "month": 2,
+                    "second": 3,
+                    "microsecond": 171000,
+                    "year": 2017,
+                    "day": 24,
+                    "minute": 0
+                },
+                "AvailabilityZones": [
+                    "us-east-1a",
+                    "us-east-1b"
+                ],
+                "HealthCheckType": "EC2",
+                "NewInstancesProtectedFromScaleIn": false
+            }
+        ],
+        "ResponseMetadata": {
+            "RetryAttempts": 0,
+            "HTTPStatusCode": 200,
+            "RequestId": "770b2115-fac8-11e6-ac2c-5ff00137fb8b",
+            "HTTPHeaders": {
+                "x-amzn-requestid": "770b2115-fac8-11e6-ac2c-5ff00137fb8b",
+                "vary": "Accept-Encoding",
+                "content-length": "7006",
+                "content-type": "text/xml",
+                "date": "Fri, 24 Feb 2017 19:35:57 GMT"
+            }
+        }
+    }
+}
diff --git a/tests/data/placebo/test_asg_propagate_tag_no_instances/ec2.CreateTags_1.json b/tests/data/placebo/test_asg_propagate_tag_no_instances/ec2.CreateTags_1.json
new file mode 100644
index 000000000..420881faf
--- /dev/null
+++ b/tests/data/placebo/test_asg_propagate_tag_no_instances/ec2.CreateTags_1.json
@@ -0,0 +1,20 @@
+{
+    "status_code": 400,
+    "data": {
+        "Error": {
+            "Code": "MissingParameter",
+            "Message": "The request must contain the parameter resourceIdSet"
+        },
+        "ResponseMetadata": {
+            "RequestId": "f229a23a-def5-4288-8ee0-f754ea63eda2",
+            "HTTPStatusCode": 400,
+            "HTTPHeaders": {
+                "transfer-encoding": "chunked",
+                "date": "Thu, 21 Nov 2019 18:49:02 GMT",
+                "connection": "close",
+                "server": "AmazonEC2"
+            },
+            "RetryAttempts": 0
+        }
+    }
+}
diff --git a/tests/data/placebo/test_asg_propagate_tag_no_instances/ec2.DeleteTags_1.json b/tests/data/placebo/test_asg_propagate_tag_no_instances/ec2.DeleteTags_1.json
new file mode 100644
index 000000000..8a17226c3
--- /dev/null
+++ b/tests/data/placebo/test_asg_propagate_tag_no_instances/ec2.DeleteTags_1.json
@@ -0,0 +1,9 @@
+{
+    "status_code": 200,
+    "data": {
+        "ResponseMetadata": {
+            "HTTPStatusCode": 200,
+            "RequestId": "1b312937-e532-443a-99bd-1dab530b4a84"
+        }
+    }
+}
diff --git a/tests/test_asg.py b/tests/test_asg.py
index a4b7d75b5..a7c3d5b41 100644
--- a/tests/test_asg.py
+++ b/tests/test_asg.py
@@ -819,6 +819,28 @@ class AutoScalingTest(BaseTest):
         self.assertEqual(len(resources), 1)
         self.assertEqual(resources[0]["AutoScalingGroupName"], "c7n-asg-np-missing")
 
+    def test_asg_propagate_tag_no_instances(self):
+        factory = self.replay_flight_data("test_asg_propagate_tag_no_instances")
+        p = self.load_policy(
+            {
+                "name": "asg-tag",
+                "resource": "asg",
+                "filters": [{"tag:Platform": "ubuntu"}],
+                "actions": [
+                    {
+                        "type": "propagate-tags",
+                        "trim": True,
+                        "tags": ["CustomerId", "Platform"],
+                    },
+                ],
+            },
+            session_factory=factory,
+        )
+
+        resources = p.run()
+        self.assertEqual(len(resources), 1)
+        self.assertEqual(resources[0]["AutoScalingGroupName"], "c7n.asg.ec2.01")
+
     def test_asg_filter_capacity_delta_match(self):
         factory = self.replay_flight_data("test_asg_filter_capacity_delta_match")
         p = self.load_policy(

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc
3.8
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
apipkg==1.5
appdirs==1.4.4
argcomplete==1.11.1
attrs==19.3.0
aws-xray-sdk==2.5.0
bleach==3.1.5
boto3==1.13.14
botocore==1.16.14
-e git+https://github.com/cloud-custodian/cloud-custodian.git@dc087d1902e82d74d120a65af2ee22ec27f0d9b2#egg=c7n
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
coverage==5.1
cryptography==2.9.2
distlib==0.3.0
docutils==0.15.2
exceptiongroup==1.2.2
execnet==1.7.1
filelock==3.0.12
flake8==3.8.1
future==0.18.2
idna==2.9
importlib-metadata==1.6.0
iniconfig==2.1.0
jeepney==0.4.3
jmespath==0.10.0
jsonpatch==1.25
jsonpickle==1.4.1
jsonpointer==2.0
jsonschema==3.2.0
keyring==21.2.1
mccabe==0.6.1
mock==4.0.2
more-itertools==8.3.0
multidict==4.7.6
packaging==20.4
pkginfo==1.5.0.1
placebo==0.9.0
pluggy==1.5.0
psutil==5.7.0
py==1.8.1
pycodestyle==2.6.0
pycparser==2.20
pyflakes==2.2.0
Pygments==2.6.1
pyparsing==2.4.7
pyrsistent==0.16.0
pytest==8.3.5
pytest-asyncio==0.24.0
pytest-cov==2.8.1
pytest-forked==1.1.3
pytest-mock==3.14.0
pytest-sugar==0.9.3
pytest-xdist==1.32.0
python-dateutil==2.8.1
PyYAML==5.3.1
readme-renderer==26.0
requests==2.23.0
requests-toolbelt==0.9.1
s3transfer==0.3.3
SecretStorage==3.1.2
six==1.14.0
tabulate==0.8.7
termcolor==1.1.0
toml==0.10.1
tomli==2.2.1
tox==3.15.1
tqdm==4.46.0
twine==3.1.1
urllib3==1.25.9
vcrpy==4.0.2
virtualenv==20.0.21
wcwidth==0.1.9
webencodings==0.5.1
wrapt==1.12.1
yarl==1.4.2
zipp==3.1.0

name: cloud-custodian
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=24.2=py38h06a4308_0
  - python=3.8.20=he870216_0
  - readline=8.2=h5eee18b_0
  - setuptools=75.1.0=py38h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.44.0=py38h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - apipkg==1.5
      - appdirs==1.4.4
      - argcomplete==1.11.1
      - attrs==19.3.0
      - aws-xray-sdk==2.5.0
      - bleach==3.1.5
      - boto3==1.13.14
      - botocore==1.16.14
      - c7n==0.9.2
      - certifi==2020.4.5.1
      - cffi==1.14.0
      - chardet==3.0.4
      - coverage==5.1
      - cryptography==2.9.2
      - distlib==0.3.0
      - docutils==0.15.2
      - exceptiongroup==1.2.2
      - execnet==1.7.1
      - filelock==3.0.12
      - flake8==3.8.1
      - future==0.18.2
      - idna==2.9
      - importlib-metadata==1.6.0
      - iniconfig==2.1.0
      - jeepney==0.4.3
      - jmespath==0.10.0
      - jsonpatch==1.25
      - jsonpickle==1.4.1
      - jsonpointer==2.0
      - jsonschema==3.2.0
      - keyring==21.2.1
      - mccabe==0.6.1
      - mock==4.0.2
      - more-itertools==8.3.0
      - multidict==4.7.6
      - packaging==20.4
      - pkginfo==1.5.0.1
      - placebo==0.9.0
      - pluggy==1.5.0
      - psutil==5.7.0
      - py==1.8.1
      - pycodestyle==2.6.0
      - pycparser==2.20
      - pyflakes==2.2.0
      - pygments==2.6.1
      - pyparsing==2.4.7
      - pyrsistent==0.16.0
      - pytest==8.3.5
      - pytest-asyncio==0.24.0
      - pytest-cov==2.8.1
      - pytest-forked==1.1.3
      - pytest-mock==3.14.0
      - pytest-sugar==0.9.3
      - pytest-xdist==1.32.0
      - python-dateutil==2.8.1
      - pyyaml==5.3.1
      - readme-renderer==26.0
      - requests==2.23.0
      - requests-toolbelt==0.9.1
      - s3transfer==0.3.3
      - secretstorage==3.1.2
      - six==1.14.0
      - tabulate==0.8.7
      - termcolor==1.1.0
      - toml==0.10.1
      - tomli==2.2.1
      - tox==3.15.1
      - tqdm==4.46.0
      - twine==3.1.1
      - urllib3==1.25.9
      - vcrpy==4.0.2
      - virtualenv==20.0.21
      - wcwidth==0.1.9
      - webencodings==0.5.1
      - wrapt==1.12.1
      - yarl==1.4.2
      - zipp==3.1.0
prefix: /opt/conda/envs/cloud-custodian

tests/test_asg.py::AutoScalingTest::test_asg_propagate_tag_no_instances
tests/test_asg.py::LaunchConfigTest::test_config_delete tests/test_asg.py::LaunchConfigTest::test_config_unused tests/test_asg.py::TestUserData::test_regex_filter tests/test_asg.py::AutoScalingTemplateTest::test_asg_mixed_instance_templates tests/test_asg.py::AutoScalingTest::test_asg_config_filter tests/test_asg.py::AutoScalingTest::test_asg_delete tests/test_asg.py::AutoScalingTest::test_asg_filter_capacity_delta_match tests/test_asg.py::AutoScalingTest::test_asg_filter_capacity_delta_nomatch tests/test_asg.py::AutoScalingTest::test_asg_image_age_filter tests/test_asg.py::AutoScalingTest::test_asg_image_age_filter_deleted_config tests/test_asg.py::AutoScalingTest::test_asg_image_age_filter_template tests/test_asg.py::AutoScalingTest::test_asg_invalid_filter_bad tests/test_asg.py::AutoScalingTest::test_asg_invalid_filter_good tests/test_asg.py::AutoScalingTest::test_asg_mark_for_op tests/test_asg.py::AutoScalingTest::test_asg_mark_for_op_hours tests/test_asg.py::AutoScalingTest::test_asg_marked_for_op_hours tests/test_asg.py::AutoScalingTest::test_asg_non_encrypted_filter tests/test_asg.py::AutoScalingTest::test_asg_non_encrypted_filter_with_templates tests/test_asg.py::AutoScalingTest::test_asg_not_propagate_tag_match tests/test_asg.py::AutoScalingTest::test_asg_not_propagate_tag_missing tests/test_asg.py::AutoScalingTest::test_asg_propagate_tag_filter tests/test_asg.py::AutoScalingTest::test_asg_propagate_tag_missing tests/test_asg.py::AutoScalingTest::test_asg_remove_tag tests/test_asg.py::AutoScalingTest::test_asg_rename_tag tests/test_asg.py::AutoScalingTest::test_asg_resize_restore_from_tag tests/test_asg.py::AutoScalingTest::test_asg_resize_save_to_tag tests/test_asg.py::AutoScalingTest::test_asg_resize_to_current tests/test_asg.py::AutoScalingTest::test_asg_resume tests/test_asg.py::AutoScalingTest::test_asg_security_group tests/test_asg.py::AutoScalingTest::test_asg_security_group_not_matched tests/test_asg.py::AutoScalingTest::test_asg_subnet tests/test_asg.py::AutoScalingTest::test_asg_suspend tests/test_asg.py::AutoScalingTest::test_asg_suspend_when_no_instances tests/test_asg.py::AutoScalingTest::test_asg_tag_and_propagate tests/test_asg.py::AutoScalingTest::test_asg_third_ami_filter tests/test_asg.py::AutoScalingTest::test_asg_vpc_filter tests/test_asg.py::AutoScalingTest::test_valid_asg_with_launch_templates
c7n/resources/asg.py
c7n/resources/asg.py