Skip to content

Instantly share code, notes, and snippets.

@aqilzeeshan
aqilzeeshan / Ansible
Created December 15, 2024 10:48
Ansible
Ansible
@aqilzeeshan
aqilzeeshan / AWS Security
Created November 3, 2024 09:38
AWS Security
AWS Security
@aqilzeeshan
aqilzeeshan / Vagrant & Docker
Last active October 26, 2024 20:50
Vagrant & Docker
vagrant init generic/ubuntu2204
vagrant up
vagrant ssh
cat /etc/os-release
uname -a
sudo apt install net-tools
ifconfig
pstree
service ssh status OR systemctl status ssh
exit
@aqilzeeshan
aqilzeeshan / WebSocket.yaml
Created December 9, 2021 13:53
WebSocket Chat in AWS
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: SAM Template for serverless WebSocket chat example
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
CodeUri: websocket_demo/
MemorySize: 1024
@aqilzeeshan
aqilzeeshan / PreSignedURL-CF.yml
Last active November 11, 2021 19:08
PreSignedURL - CloudFormation template
AWSTemplateFormatVersion: 2010-09-09
Parameters:
BucketPrefix:
Type: String
Default: video-storage
FromEmail:
Type: String
ToEmail:
Type: String
Resources:
@aqilzeeshan
aqilzeeshan / LambdaInvokePermission.yml
Created October 29, 2021 21:09
Lambda Invoke Permission
lambdaInvokePermissions:
Type: AWS::Lambda::Permission
Properties:
FunctionName: !GetAtt LambdaFunction.Arn
Action: lambda:InvokeFunction
Principal: events.amazonaws.com
SourceArn: !GetAtt LambdaFunctionSchedule.Arn
@aqilzeeshan
aqilzeeshan / AttachDetachTarget.yml
Created October 29, 2021 21:07
Attach Detach Target
- 'events:PutTargets'
- 'events:RemoveTargets'
@aqilzeeshan
aqilzeeshan / PuttingTargetInLambda.yml
Created October 29, 2021 21:05
Putting target of EventsBridge Rule in Lambda
trigger_rule_name = os.environ['EventTriggerRuleName']
eventsbridge_client = boto3.client('events')
if event['RequestType'] == 'Create':
...
try:
eventsbridge_client.put_targets(Rule=trigger_rule_name,
Targets=[{
'Arn': context.invoked_function_arn,
'Id': 'FIS-Experiment-Lambda-trigger',
}])
@aqilzeeshan
aqilzeeshan / Passing.yml
Created October 29, 2021 21:03
Passing Environment Variable to Lambda
LambdaFunction:
Type: 'AWS::Lambda::Function'
Properties:
Environment:
Variables:
FISExperimentId:
'Fn::GetAtt':
- 'CHAOSSIM'
- Id
EventTriggerRuleName: !Ref LambdaFunctionSchedule
@aqilzeeshan
aqilzeeshan / Separating.yml
Created October 29, 2021 20:33
Separating Create,Update and Delete calls from scheduled calls from EventBridge rules
if event.get('RequestType') != None:
if event['RequestType'] == 'Create':
...
if event['RequestType'] == 'Update':
...
if event['RequestType'] == 'Delete':
...
else:
...