Skip to content

Commit

Permalink
Send launch errors via EventBridge
Browse files Browse the repository at this point in the history
  • Loading branch information
farski committed Jun 3, 2024
1 parent e98bbcd commit d288a37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
1 change: 0 additions & 1 deletion spire/templates/root.yml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ Resources:
RootStackName: !Ref AWS::StackName
RootStackId: !Ref AWS::StackName
NestedChangeSetScrubbingResourcesState: !Ref NestedChangeSetScrubbingResourcesState
SlackMessageRelaySnsTopicArn: !Ref SlackMessageRelayTopicArn
AuthorizedKeys: !Join [",", !Ref AuthorizedKeys]
VpcPublicSubnet1Id: !GetAtt SharedVpcStack.Outputs.PublicSubnet1Id
VpcPublicSubnet2Id: !GetAtt SharedVpcStack.Outputs.PublicSubnet2Id
Expand Down
16 changes: 6 additions & 10 deletions spire/templates/shared-ecs/asg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Parameters:
RootStackName: { Type: String }
RootStackId: { Type: String }
NestedChangeSetScrubbingResourcesState: { Type: String }
SlackMessageRelaySnsTopicArn: { Type: String }
AuthorizedKeys: { Type: CommaDelimitedList }
VpcPublicSubnet1Id: { Type: AWS::EC2::Subnet::Id }
VpcPublicSubnet2Id: { Type: AWS::EC2::Subnet::Id }
Expand Down Expand Up @@ -76,11 +75,12 @@ Resources:
Policies:
- PolicyDocument:
Statement:
- Action: sns:Publish
- Action: events:PutEvents
Effect: Allow
Resource: !Ref SlackMessageRelaySnsTopicArn
Resource: !Sub arn:${AWS::Partition}:events:${AWS::Region}:${AWS::AccountId}:event-bus/default
Sid: AllowDefaultEventBusPut
Version: "2012-10-17"
PolicyName: SlackRelaySnsPublish
PolicyName: DefaultEventBus
Tags:
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
Expand Down Expand Up @@ -268,10 +268,8 @@ Resources:
INSTANCE_ID=`ec2-metadata -i | cut -d " " -f 2`
aws sns publish \
--region ${region} \
--topic-arn ${topic} \
--message '{ "channel": "${channel}", "username": "AWS Auto Scaling", "icon_emoji": ":ops-autoscaling:", "text": "${text}" }'
aws events put-events \
--entries 'Source="org.prx.spire.asg",DetailType="Slack Message Relay Message Payload",Detail="{ \"channel\": \"${channel}\", \"username\": \"AWS Auto Scaling\", \"icon_emoji\": \":ops-autoscaling:\", \"text\": \"${text}\" }"'
aws autoscaling set-instance-health \
--instance-id "$INSTANCE_ID" \
Expand All @@ -291,8 +289,6 @@ Resources:
text: !Sub >-
EC2 instance `'"$INSTANCE_ID"'` could not connect to `${SharedRedisReplicationGroupEndpointAddress}`
at `'"$IP"'`. It will be marked as *unhealthy* in its auto scaling group and get replaced.
topic: !Ref SlackMessageRelaySnsTopicArn
region: !Select [3, !Split [":", !Ref SlackMessageRelaySnsTopicArn]]
02_add_authorized_keys:
# For more information, see:
# https://github.com/PRX/internal/wiki/AWS:-Developer-Access
Expand Down

0 comments on commit d288a37

Please sign in to comment.