1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use crate::;
/// [AWS::Lambda::Version]
///
/// The AWS::Lambda::Version resource creates a version from the current code
/// and configuration of a function. Use versions to create a snapshot of your function code
/// and configuration that doesn't change.
///
/// ```
/// use four::{
/// LogicalId, Account, Partition, arn_builder, service, r#ref,
/// lambda::{
/// resource::{Function, Version},
/// Handler, Runtime, VersionDescription, ProvisionedConcurrencyConfiguration,
/// },
/// iam::RoleArn,
/// };
///
/// let account = Account::try_from("123456789012").unwrap();
/// let role_arn: RoleArn = arn_builder("role/lambda-role", account)
/// .partition(Partition::Aws)
/// .build(service::IAM)
/// .into();
/// let function_id = LogicalId::try_from("function").unwrap();
/// let handler = Handler::try_from("bootstrap").unwrap();
/// let runtime = Runtime::ProvidedAl2023;
/// let function = Function::zip(function_id, "mybucket", "mykey.zip", role_arn.into(), handler, runtime);
///
/// let version_id = LogicalId::try_from("version").unwrap();
/// let function_name = r#ref(function).into();
/// let version = Version::new(version_id, function_name)
/// .description(VersionDescription::try_new("v1").unwrap())
/// .provisioned_concurrency_config(ProvisionedConcurrencyConfiguration::new(20));
///
/// let lhs = serde_json::to_string(&version).unwrap();
/// let mut rhs = r#"
/// {
/// "Type": "AWS::Lambda::Version",
/// "Properties": {
/// "Description": "v1",
/// "FunctionName": { "Ref": "function" },
/// "ProvisionedConcurrencyConfig": {
/// "ProvisionedConcurrentExecutions": 20
/// }
/// }
/// }
/// "#.to_string();
/// rhs.retain(|c| c != '\n' && c != ' ');
///
/// assert_eq!(lhs, rhs);
///
/// ```
///
/// [AWS::Lambda::Version]: https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-version.html
///