(
config: &Deploy,
name: &str,
sdk_config: &SdkConfig,
binary_archive: &BinaryArchive,
progress: &Progress,
)
| 37 | |
| 38 | #[allow(clippy::too_many_arguments)] |
| 39 | pub(crate) async fn deploy( |
| 40 | config: &Deploy, |
| 41 | name: &str, |
| 42 | sdk_config: &SdkConfig, |
| 43 | binary_archive: &BinaryArchive, |
| 44 | progress: &Progress, |
| 45 | ) -> Result<DeployOutput> { |
| 46 | let lambda_client = LambdaClient::new(sdk_config); |
| 47 | |
| 48 | let compatible_runtimes = config |
| 49 | .compatible_runtimes() |
| 50 | .iter() |
| 51 | .map(|runtime| Runtime::from(runtime.as_str())) |
| 52 | .collect::<Vec<_>>(); |
| 53 | |
| 54 | let input = match &config.s3_bucket { |
| 55 | None => LayerVersionContentInput::builder() |
| 56 | .zip_file(Blob::new(binary_archive.read()?)) |
| 57 | .build(), |
| 58 | Some(bucket) => { |
| 59 | progress.set_message("uploading binary to S3"); |
| 60 | |
| 61 | let key = config.s3_key.as_deref().unwrap_or(name); |
| 62 | debug!(bucket, key, "uploading zip to S3"); |
| 63 | |
| 64 | let s3_client = S3Client::new(sdk_config); |
| 65 | let mut operation = s3_client |
| 66 | .put_object() |
| 67 | .bucket(bucket) |
| 68 | .key(key) |
| 69 | .body(ByteStream::from(binary_archive.read()?)); |
| 70 | |
| 71 | if let Some(tags) = config.s3_tags() { |
| 72 | operation = operation.tagging(tags); |
| 73 | } |
| 74 | |
| 75 | operation |
| 76 | .send() |
| 77 | .await |
| 78 | .into_diagnostic() |
| 79 | .wrap_err("failed to upload extension code to S3")?; |
| 80 | |
| 81 | LayerVersionContentInput::builder() |
| 82 | .s3_bucket(bucket) |
| 83 | .s3_key(key) |
| 84 | .build() |
| 85 | } |
| 86 | }; |
| 87 | |
| 88 | progress.set_message("publishing new layer version"); |
| 89 | |
| 90 | let output = lambda_client |
| 91 | .publish_layer_version() |
| 92 | .layer_name(name) |
| 93 | .compatible_architectures(binary_archive.architecture()) |
| 94 | .set_compatible_runtimes(Some(compatible_runtimes)) |
| 95 | .set_description(config.function_config.description.clone()) |
| 96 | .content(input) |
nothing calls this directly
no test coverage detected