Repackage and update the function code.
(self, source_zip=None, no_upload=False, docker_image_uri=None)
| 1036 | click.echo("WebSocket URL: " + click.style(ws_url, bold=True)) |
| 1037 | |
| 1038 | def update(self, source_zip=None, no_upload=False, docker_image_uri=None): |
| 1039 | """ |
| 1040 | Repackage and update the function code. |
| 1041 | """ |
| 1042 | |
| 1043 | if not source_zip and not docker_image_uri: |
| 1044 | # Make sure we're in a venv. |
| 1045 | self.check_venv() |
| 1046 | |
| 1047 | # Execute the prebuild script |
| 1048 | if self.prebuild_script: |
| 1049 | self.execute_prebuild_script() |
| 1050 | |
| 1051 | # Temporary version check |
| 1052 | try: |
| 1053 | updated_time = 1472581018 |
| 1054 | function_response = self.zappa.lambda_client.get_function(FunctionName=self.lambda_name) |
| 1055 | conf = function_response["Configuration"] |
| 1056 | last_updated = parser.parse(conf["LastModified"]) |
| 1057 | last_updated_unix = time.mktime(last_updated.timetuple()) |
| 1058 | except botocore.exceptions.BotoCoreError as e: |
| 1059 | click.echo(click.style(type(e).__name__, fg="red") + ": " + e.args[0]) |
| 1060 | sys.exit(-1) |
| 1061 | # https://github.com/zappa/Zappa/issues/1313 |
| 1062 | except botocore.exceptions.ClientError as e: |
| 1063 | click.echo(click.style(type(e).__name__, fg="red") + ": " + e.args[0]) |
| 1064 | sys.exit(-1) |
| 1065 | except Exception: |
| 1066 | click.echo( |
| 1067 | click.style("Warning!", fg="red") |
| 1068 | + " Couldn't get function " |
| 1069 | + self.lambda_name |
| 1070 | + " in " |
| 1071 | + self.zappa.aws_region |
| 1072 | + " - have you deployed yet?" |
| 1073 | ) |
| 1074 | sys.exit(-1) |
| 1075 | |
| 1076 | if last_updated_unix <= updated_time: |
| 1077 | click.echo( |
| 1078 | click.style("Warning!", fg="red") |
| 1079 | + " You may have upgraded Zappa since deploying this application. You will need to " |
| 1080 | + click.style("redeploy", bold=True) |
| 1081 | + " for this deployment to work properly!" |
| 1082 | ) |
| 1083 | |
| 1084 | # Make sure the necessary IAM execution roles are available |
| 1085 | if self.manage_roles: |
| 1086 | try: |
| 1087 | self.zappa.create_iam_roles() |
| 1088 | except botocore.client.ClientError: |
| 1089 | click.echo(click.style("Failed", fg="red") + " to " + click.style("manage IAM roles", bold=True) + "!") |
| 1090 | click.echo( |
| 1091 | "You may " |
| 1092 | + click.style("lack the necessary AWS permissions", bold=True) |
| 1093 | + " to automatically manage a Zappa execution role." |
| 1094 | ) |
| 1095 | click.echo( |