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
use crate::;
/// [AWS::Lambda::EventInvokeConfig]
///
/// The `AWS::Lambda::EventInvokeConfig` resource configures options
/// for asynchronous invocation on a version or an alias.
///
/// By default, Lambda retries an asynchronous invocation twice if the
/// function returns an error. It retains events in a queue for up to six hours.
/// When an event fails all processing attempts or stays in the
/// asynchronous invocation queue for too long, Lambda discards it.
///
/// ```
/// use four::{
/// LogicalId, r#ref, get_att,
/// convert::WillBe,
/// lambda::{
/// resource::{Function, EventInvokeConfig, Version},
/// Runtime, FunctionVersion, Qualifier,
/// },
/// };
///
/// let function_id = "function".try_into().unwrap();
/// let role_id = "role".try_into().unwrap();
/// let handler = "bootstrap".try_into().unwrap();
/// let runtime = Runtime::ProvidedAl2023;
/// let (function, role) = Function::zip_with_role(function_id, role_id, "mybucket", "mykey.zip", handler, runtime);
///
/// let version_id = "version".try_into().unwrap();
/// let function_name = r#ref(function.clone());
/// let version = Version::new(version_id, function_name.clone().into());
///
/// let config_id = "asyncconfig".try_into().unwrap();
/// let version: WillBe<FunctionVersion> = get_att::<FunctionVersion, _>(&version);
/// let qualifier = version.map::<Qualifier>();
/// let config = EventInvokeConfig::new(config_id, function_name, qualifier)
/// .maximum_event_age_in_seconds(300.try_into().unwrap())
/// .maximum_retry_attempts(1.try_into().unwrap());
///
/// let lhs = serde_json::to_string(&config).unwrap();
/// let mut rhs = r#"
/// {
/// "Type": "AWS::Lambda::EventInvokeConfig",
/// "Properties": {
/// "FunctionName": { "Ref": "function" },
/// "MaximumEventAgeInSeconds": 300,
/// "MaximumRetryAttempts": 1,
/// "Qualifier": { "Fn::GetAtt": ["version", "Version"] }
/// }
/// }
/// "#.to_string();
/// rhs.retain(|c| c != '\n' && c != ' ');
///
/// assert_eq!(lhs, rhs);
/// ```
///
/// [AWS::Lambda::EventInvokeConfig]: https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventinvokeconfig.html