From 3c74cc254bda98a9e6058cd65c3dd5b4fd2a2c4b Mon Sep 17 00:00:00 2001 From: FTB_lag Date: Thu, 14 Mar 2024 18:02:15 +0300 Subject: [PATCH 1/3] fix(ec2): handle unauthorized exception --- clients/client-ec2/src/waiters/waitForInstanceExists.ts | 3 +++ clients/client-ec2/src/waiters/waitForInstanceRunning.ts | 3 +++ clients/client-ec2/src/waiters/waitForInstanceStopped.ts | 3 +++ clients/client-ec2/src/waiters/waitForInstanceTerminated.ts | 3 +++ 4 files changed, 12 insertions(+) diff --git a/clients/client-ec2/src/waiters/waitForInstanceExists.ts b/clients/client-ec2/src/waiters/waitForInstanceExists.ts index b1d20422bd6e4..ee37f8564a746 100644 --- a/clients/client-ec2/src/waiters/waitForInstanceExists.ts +++ b/clients/client-ec2/src/waiters/waitForInstanceExists.ts @@ -20,6 +20,9 @@ const checkState = async (client: EC2Client, input: DescribeInstancesCommandInpu } catch (e) {} } catch (exception) { reason = exception; + if (exception.name && exception.name == "UnauthorizedOperation") { + return { state: WaiterState.FAILURE, reason }; + } if (exception.name && exception.name == "InvalidInstanceID.NotFound") { return { state: WaiterState.RETRY, reason }; } diff --git a/clients/client-ec2/src/waiters/waitForInstanceRunning.ts b/clients/client-ec2/src/waiters/waitForInstanceRunning.ts index 4713ef554e55a..da8ef76fb76d3 100644 --- a/clients/client-ec2/src/waiters/waitForInstanceRunning.ts +++ b/clients/client-ec2/src/waiters/waitForInstanceRunning.ts @@ -85,6 +85,9 @@ const checkState = async (client: EC2Client, input: DescribeInstancesCommandInpu } catch (e) {} } catch (exception) { reason = exception; + if (exception.name && exception.name == "UnauthorizedOperation") { + return { state: WaiterState.FAILURE, reason }; + } if (exception.name && exception.name == "InvalidInstanceID.NotFound") { return { state: WaiterState.RETRY, reason }; } diff --git a/clients/client-ec2/src/waiters/waitForInstanceStopped.ts b/clients/client-ec2/src/waiters/waitForInstanceStopped.ts index 2dba72c3bef4f..cc91e1cb537d3 100644 --- a/clients/client-ec2/src/waiters/waitForInstanceStopped.ts +++ b/clients/client-ec2/src/waiters/waitForInstanceStopped.ts @@ -67,6 +67,9 @@ const checkState = async (client: EC2Client, input: DescribeInstancesCommandInpu } catch (e) {} } catch (exception) { reason = exception; + if (exception.name && exception.name == "UnauthorizedOperation") { + return { state: WaiterState.FAILURE, reason }; + } } return { state: WaiterState.RETRY, reason }; }; diff --git a/clients/client-ec2/src/waiters/waitForInstanceTerminated.ts b/clients/client-ec2/src/waiters/waitForInstanceTerminated.ts index e3d98e6f935f2..8976bf987d186 100644 --- a/clients/client-ec2/src/waiters/waitForInstanceTerminated.ts +++ b/clients/client-ec2/src/waiters/waitForInstanceTerminated.ts @@ -67,6 +67,9 @@ const checkState = async (client: EC2Client, input: DescribeInstancesCommandInpu } catch (e) {} } catch (exception) { reason = exception; + if (exception.name && exception.name == "UnauthorizedOperation") { + return { state: WaiterState.FAILURE, reason }; + } } return { state: WaiterState.RETRY, reason }; }; From d67802b183abc195794f5153ad4e15fbb74b69ce Mon Sep 17 00:00:00 2001 From: FTB_lag Date: Thu, 14 Mar 2024 22:03:40 +0300 Subject: [PATCH 2/3] Revert "fix(ec2): handle unauthorized exception" This reverts commit 3c74cc254bda98a9e6058cd65c3dd5b4fd2a2c4b. --- clients/client-ec2/src/waiters/waitForInstanceExists.ts | 3 --- clients/client-ec2/src/waiters/waitForInstanceRunning.ts | 3 --- clients/client-ec2/src/waiters/waitForInstanceStopped.ts | 3 --- clients/client-ec2/src/waiters/waitForInstanceTerminated.ts | 3 --- 4 files changed, 12 deletions(-) diff --git a/clients/client-ec2/src/waiters/waitForInstanceExists.ts b/clients/client-ec2/src/waiters/waitForInstanceExists.ts index ee37f8564a746..b1d20422bd6e4 100644 --- a/clients/client-ec2/src/waiters/waitForInstanceExists.ts +++ b/clients/client-ec2/src/waiters/waitForInstanceExists.ts @@ -20,9 +20,6 @@ const checkState = async (client: EC2Client, input: DescribeInstancesCommandInpu } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "UnauthorizedOperation") { - return { state: WaiterState.FAILURE, reason }; - } if (exception.name && exception.name == "InvalidInstanceID.NotFound") { return { state: WaiterState.RETRY, reason }; } diff --git a/clients/client-ec2/src/waiters/waitForInstanceRunning.ts b/clients/client-ec2/src/waiters/waitForInstanceRunning.ts index da8ef76fb76d3..4713ef554e55a 100644 --- a/clients/client-ec2/src/waiters/waitForInstanceRunning.ts +++ b/clients/client-ec2/src/waiters/waitForInstanceRunning.ts @@ -85,9 +85,6 @@ const checkState = async (client: EC2Client, input: DescribeInstancesCommandInpu } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "UnauthorizedOperation") { - return { state: WaiterState.FAILURE, reason }; - } if (exception.name && exception.name == "InvalidInstanceID.NotFound") { return { state: WaiterState.RETRY, reason }; } diff --git a/clients/client-ec2/src/waiters/waitForInstanceStopped.ts b/clients/client-ec2/src/waiters/waitForInstanceStopped.ts index cc91e1cb537d3..2dba72c3bef4f 100644 --- a/clients/client-ec2/src/waiters/waitForInstanceStopped.ts +++ b/clients/client-ec2/src/waiters/waitForInstanceStopped.ts @@ -67,9 +67,6 @@ const checkState = async (client: EC2Client, input: DescribeInstancesCommandInpu } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "UnauthorizedOperation") { - return { state: WaiterState.FAILURE, reason }; - } } return { state: WaiterState.RETRY, reason }; }; diff --git a/clients/client-ec2/src/waiters/waitForInstanceTerminated.ts b/clients/client-ec2/src/waiters/waitForInstanceTerminated.ts index 8976bf987d186..e3d98e6f935f2 100644 --- a/clients/client-ec2/src/waiters/waitForInstanceTerminated.ts +++ b/clients/client-ec2/src/waiters/waitForInstanceTerminated.ts @@ -67,9 +67,6 @@ const checkState = async (client: EC2Client, input: DescribeInstancesCommandInpu } catch (e) {} } catch (exception) { reason = exception; - if (exception.name && exception.name == "UnauthorizedOperation") { - return { state: WaiterState.FAILURE, reason }; - } } return { state: WaiterState.RETRY, reason }; }; From 8237e59df4c58b6f549a75d87bd77c5381297de3 Mon Sep 17 00:00:00 2001 From: FTB_lag Date: Thu, 14 Mar 2024 23:35:14 +0300 Subject: [PATCH 3/3] fix(ec2): handle unauthorized exception --- codegen/sdk-codegen/aws-models/ec2.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/codegen/sdk-codegen/aws-models/ec2.json b/codegen/sdk-codegen/aws-models/ec2.json index b101247695e0b..8d956f1ec83f9 100644 --- a/codegen/sdk-codegen/aws-models/ec2.json +++ b/codegen/sdk-codegen/aws-models/ec2.json @@ -32067,6 +32067,12 @@ "matcher": { "errorType": "InvalidInstanceID.NotFound" } + }, + { + "state": "failure", + "matcher": { + "errorType": "UnauthorizedOperation" + } } ], "minDelay": 5 @@ -32118,6 +32124,12 @@ "matcher": { "errorType": "InvalidInstanceID.NotFound" } + }, + { + "state": "failure", + "matcher": { + "errorType": "UnauthorizedOperation" + } } ], "minDelay": 15 @@ -32153,6 +32165,12 @@ "comparator": "anyStringEquals" } } + }, + { + "state": "failure", + "matcher": { + "errorType": "UnauthorizedOperation" + } } ], "minDelay": 15 @@ -32188,6 +32206,12 @@ "comparator": "anyStringEquals" } } + }, + { + "state": "failure", + "matcher": { + "errorType": "UnauthorizedOperation" + } } ], "minDelay": 15