Repository: Miserlou/Zappa

Issue:
API Gateway is not deployed on `zappa update`
This means updates are applied but do not have any effect. It is mainly an issue if something changes related to Authorization but it also means the following parameters cannot be updated after the initial deploy:

```
cache_cluster_enabled
cache_cluster_size
cloudwatch_log_level
cloudwatch_data_trace
cloudwatch_metrics_enabled
```

Edit: Looking at the code more carefully, the settings above are actually updated on update, it only affects changes to the resources itself which is currently mainly modifications regarding Authorization.

API Gateway is not deployed on `zappa update`
This means updates are applied but do not have any effect. It is mainly an issue if something changes related to Authorization but it also means the following parameters cannot be updated after the initial deploy:

```
cache_cluster_enabled
cache_cluster_size
cloudwatch_log_level
cloudwatch_data_trace
cloudwatch_metrics_enabled
```

Edit: Looking at the code more carefully, the settings above are actually updated on update, it only affects changes to the resources itself which is currently mainly modifications regarding Authorization.



Discussion:
Yep. There are a number of settings that remain unaffected by update for lambdas as well. Right now, the guidance is generally to redeploy. I know this is inconvenient, but luckily Zappa's domain handling makes this relatively smooth.

Since the CloudFormation stack is actually updated and Zappa supports this functionality, I guess the changes should also be applied. I'll open a PR.

Yep. There are a number of settings that remain unaffected by update for lambdas as well. Right now, the guidance is generally to redeploy. I know this is inconvenient, but luckily Zappa's domain handling makes this relatively smooth.

Since the CloudFormation stack is actually updated and Zappa supports this functionality, I guess the changes should also be applied. I'll open a PR.


Resolving patch:
diff --git a/zappa/cli.py b/zappa/cli.py
--- a/zappa/cli.py
+++ b/zappa/cli.py
@@ -315,20 +315,10 @@ def deploy(self):
                                                         self.authorizer)
 
             self.zappa.update_stack(self.lambda_name, self.s3_bucket_name, wait=True)
-            api_id = self.zappa.get_api_id(self.lambda_name)
 
             # Deploy the API!
-            cache_cluster_enabled = self.stage_config.get('cache_cluster_enabled', False)
-            cache_cluster_size = str(self.stage_config.get('cache_cluster_size', .5))
-            endpoint_url = self.zappa.deploy_api_gateway(
-                                        api_id=api_id,
-                                        stage_name=self.api_stage,
-                                        cache_cluster_enabled=cache_cluster_enabled,
-                                        cache_cluster_size=cache_cluster_size,
-                                        cloudwatch_log_level=self.zappa_settings[self.api_stage].get('cloudwatch_log_level', 'OFF'),
-                                        cloudwatch_data_trace=self.zappa_settings[self.api_stage].get('cloudwatch_data_trace', False),
-                                        cloudwatch_metrics_enabled=self.zappa_settings[self.api_stage].get('cloudwatch_metrics_enabled', False),
-                                    )
+            api_id = self.zappa.get_api_id(self.lambda_name)
+            endpoint_url = self.deploy_api_gateway(api_id)
             deployment_string = deployment_string + ": {}".format(endpoint_url)
 
             # Create/link API key
@@ -424,25 +414,19 @@ def update(self):
         if self.use_apigateway:
 
             self.zappa.create_stack_template(self.lambda_arn,
-                                                        self.lambda_name,
-                                                        self.api_key_required,
-                                                        self.integration_content_type_aliases,
-                                                        self.iam_authorization,
-                                                        self.authorizer)
+                                             self.lambda_name,
+                                             self.api_key_required,
+                                             self.integration_content_type_aliases,
+                                             self.iam_authorization,
+                                             self.authorizer)
             self.zappa.update_stack(self.lambda_name, self.s3_bucket_name, wait=True, update_only=True)
 
-            self.zappa.update_stage_config(
-                self.lambda_name,
-                self.api_stage,
-                self.zappa_settings[self.api_stage].get('cloudwatch_log_level', 'OFF'),
-                self.zappa_settings[self.api_stage].get('cloudwatch_data_trace', False),
-                self.zappa_settings[self.api_stage].get('cloudwatch_metrics_enabled', False)
-            )
+            api_id = self.zappa.get_api_id(self.lambda_name)
+            endpoint_url = self.deploy_api_gateway(api_id)
 
             if self.stage_config.get('domain', None):
                 endpoint_url = self.stage_config.get('domain')
-            else:
-                endpoint_url = self.zappa.get_api_url(self.lambda_name, self.api_stage)
+
         else:
             endpoint_url = None
 
@@ -1343,6 +1327,19 @@ def collision_warning(self, item):
             if namespace_collision in item:
                 click.echo(click.style("Warning!", fg="yellow", bold=True) + " You may have a namespace collision with " + click.style(item, bold=True) + "! You may want to rename that file.")
 
+    def deploy_api_gateway(self, api_id):
+        cache_cluster_enabled = self.stage_config.get('cache_cluster_enabled', False)
+        cache_cluster_size = str(self.stage_config.get('cache_cluster_size', .5))
+        endpoint_url = self.zappa.deploy_api_gateway(
+            api_id=api_id,
+            stage_name=self.api_stage,
+            cache_cluster_enabled=cache_cluster_enabled,
+            cache_cluster_size=cache_cluster_size,
+            cloudwatch_log_level=self.zappa_settings[self.api_stage].get('cloudwatch_log_level', 'OFF'),
+            cloudwatch_data_trace=self.zappa_settings[self.api_stage].get('cloudwatch_data_trace', False),
+            cloudwatch_metrics_enabled=self.zappa_settings[self.api_stage].get('cloudwatch_metrics_enabled', False),
+        )
+        return endpoint_url
 
 
 ####################################################################


Test patch: