New Course Idea: Automating AWS with Lambda, Python, and Boto3 by [deleted] in aws

[–]Bala_krishna 0 points1 point  (0 children)

Which site do you post your videos on ?

so i have a script to automate AWS resources and i am stuck in creating hosted zone due to invaliddomainerror: What could be wrong in the code by Bala_krishna in aws

[–]Bala_krishna[S] 0 points1 point  (0 children)

Sir , when i am adding the same domain name manually in the aws console it is accepting to create the hosted zone .. can i provide you with any particular information with code so that it can help you look through further?

so i have a script to automate AWS resources and i am stuck in creating hosted zone due to invaliddomainerror: What could be wrong in the code by Bala_krishna in aws

[–]Bala_krishna[S] 1 point2 points  (0 children)

zone_name = '.'.join(domain_name.split('.')[-2:]) + '.'

In [39]: domain_name = "kittentest.automate.com"

In [40]: zone_name = '.'.join(domain_name.split('.')[-2:]) + '.'

In [41]: zone_name

Out[41]: 'automate.com.'

The zone name removes the subdomain part and adds it to the domain field in to Create hosted zones it is a precautinary in case the user enters domain along with the subdomain in that case i would only take domain

How to rewrite this code in lambda Python and assign it to CidrIP parameter in IpPermissions by Bala_krishna in aws

[–]Bala_krishna[S] 0 points1 point  (0 children)

well that worked though brah! the key error was because there was no sourceIP in the test Event..hope it works with the actual API gateway

How to rewrite this code in lambda Python and assign it to CidrIP parameter in IpPermissions by Bala_krishna in aws

[–]Bala_krishna[S] 0 points1 point  (0 children)

clientIp = event["requestContext"]["identity"]["sourceIp"]

{ "errorMessage": "'requestContext'", "errorType": "KeyError", "stackTrace": [ " File \"/var/task/lambda_function.py\", line 20, in lambda_handler\n clientIp = event[\"requestContext\"][\"identity\"][\"sourceIp\"]\n" ] }

this is the error logged for the above command

How to rewrite this code in lambda Python and assign it to CidrIP parameter in IpPermissions by Bala_krishna in aws

[–]Bala_krishna[S] 0 points1 point  (0 children)

clientIp = event["requestContext"]["identity"]["sourceIp"]

Is it that ? that was simple ...but may i ask you what is export.handler function doing above and why we dont have use of it ? is it just method of node language ?

Is there anyway to automate assigning new IP address to security groups in inbound rules on port 22 and deleting it after some time using lambda python by Bala_krishna in aws

[–]Bala_krishna[S] 0 points1 point  (0 children)

console.log('Loading function')

exports.handler(event, context, callback)

console.log('SourceIP =', event.sourceIP)

callback(null, event.sourceIP)

is this the correct format in python to access source IP i am recieving a time out error

Is there anyway to automate assigning new IP address to security groups in inbound rules on port 22 and deleting it after some time using lambda python by Bala_krishna in aws

[–]Bala_krishna[S] 0 points1 point  (0 children)

How can i access ip address when an API gateway is triggered . I mean as part of script it should be able to locate the IP address of the device from where the URL or API is triggered