Skip to content

Commit 462623d

Browse files
committed
Remove AZ rebalance suspension lambda
1 parent 974946d commit 462623d

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

templates/aws-stack.yml

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,62 +1080,6 @@ Resources:
10801080
AutoScalingReplacingUpdate:
10811081
WillReplace: true
10821082

1083-
AsgProcessSuspenderRole:
1084-
Type: AWS::IAM::Role
1085-
Properties:
1086-
PermissionsBoundary: !If [ SetInstanceRolePermissionsBoundaryARN, !Ref InstanceRolePermissionsBoundaryARN, !Ref "AWS::NoValue" ]
1087-
AssumeRolePolicyDocument:
1088-
Version: 2012-10-17
1089-
Statement:
1090-
- Effect: Allow
1091-
Principal:
1092-
Service:
1093-
- lambda.amazonaws.com
1094-
Action:
1095-
- sts:AssumeRole
1096-
ManagedPolicyArns:
1097-
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
1098-
Policies:
1099-
- PolicyName: AsgProcessModification
1100-
PolicyDocument:
1101-
Version: 2012-10-17
1102-
Statement:
1103-
- Effect: Allow
1104-
Action:
1105-
- 'autoscaling:SuspendProcesses'
1106-
Resource: !Sub arn:${AWS::Partition}:autoscaling:${AWS::Region}:${AWS::AccountId}:autoScalingGroup:*:autoScalingGroupName/${AWS::StackName}-AgentAutoScaleGroup-*
1107-
1108-
AzRebalancingSuspenderFunction:
1109-
Type: AWS::Lambda::Function
1110-
Properties:
1111-
Description: 'Disables AZ Rebalancing on the agent ASG'
1112-
Code:
1113-
ZipFile: |
1114-
import cfnresponse
1115-
import boto3
1116-
def handler(event, context):
1117-
try:
1118-
if event['RequestType'] == 'Delete':
1119-
cfnresponse.send(event, context, cfnresponse.SUCCESS, {}, "CustomResourcePhysicalID")
1120-
else:
1121-
client = boto3.client('autoscaling')
1122-
props = event['ResourceProperties']
1123-
response = client.suspend_processes(AutoScalingGroupName=props['AutoScalingGroupName'], ScalingProcesses=['AZRebalance'])
1124-
cfnresponse.send(event, context, cfnresponse.SUCCESS, {}, "CustomResourcePhysicalID")
1125-
except BaseException as err:
1126-
print('ERROR: ', err)
1127-
cfnresponse.send(event, context, cfnresponse.FAILED, {}, "CustomResourcePhysicalID")
1128-
Handler: index.handler
1129-
Role: !GetAtt AsgProcessSuspenderRole.Arn
1130-
Runtime: 'python3.7'
1131-
1132-
AzRebalancingSuspender:
1133-
Type: AWS::CloudFormation::CustomResource
1134-
Version: 1.0
1135-
Properties:
1136-
ServiceToken: !GetAtt AzRebalancingSuspenderFunction.Arn
1137-
AutoScalingGroupName: !Ref AgentAutoScaleGroup
1138-
11391083
SecurityGroup:
11401084
Type: AWS::EC2::SecurityGroup
11411085
Condition: CreateSecurityGroup

0 commit comments

Comments
 (0)