iann0036 / AWSConsoleRecorder

Records actions made in the AWS Management Console and outputs the equivalent CLI/SDK commands and CloudFormation/Terraform templates.
MIT License
1.43k stars 86 forks source link

Multiple Lambda functions creation #43

Open alexcasalboni opened 5 years ago

alexcasalboni commented 5 years ago

Describe the bug When I created a Lambda function, I see 5 functions created instead.

Related Mapping lambda.CreateFunction

Related Language All of them

To Reproduce Steps to reproduce the behavior:

  1. Go to https://console.aws.amazon.com/lambda/
  2. Click on 'Create function' (top right)
  3. Configure a Function a name and runtime
  4. Click on 'Create function' (bottom right)

Expected behavior The function is created correctly, but in the recorded calls I see 5 function creations.

Additional context You can find the recording here.

iann0036 commented 5 years ago

Fascinating, can replicate. Looks like this may be a console bug?

I'll reach out to the technical community for help.

rahulbaisla commented 5 years ago

I Checked in the Browser -> inspect element -> Network tab, there is only 1 POST request to createfunction. Seems correct behavior in the AWS Console.

Screen Shot 2019-07-07 at 11 08 50 am

However, It seems AWS Console Recorder does not clear previous recordings. See below output from AWS Console Recorder when I tried to create lambda function in three different regions.



#pip install boto3

import boto3

lambda_client = boto3.client('lambda', region_name='us-east-2')

response = lambda_client.create_function(
    Code={
        'ZipFile': 'UEsDBAoAAAAIAKoE504/MdkflAAAAL4AAAAIAAAAaW5kZXguanM9TcsKgkAU3fsVt5UKodJSsU0tIiIX9QOjc62BecjcayTRvzcpeDbncB4cfA/OM2VPYaVGDzUImmwHCb7Qcgr1Hj4RBOQ53JtjA8oMGk3IZrdzlhg80hAEhvVS/oNY8EgHJ7GEXVFs16B1cirhfGuuGbFX9qH6KYlPqLWD3jsDF2FaKTZxumy+1UweefR2/aqi4P8AUEsBAh4DCgAAAAgAqgTnTj8x2R+UAAAAvgAAAAgAAAAAAAAAAAAAALSBAAAAAGluZGV4LmpzUEsFBgAAAAABAAEANgAAALoAAAAAAA=='
    },
    Description='',
    FunctionName='**useast2afterdeleting**',
    Handler='index.handler',
    MemorySize=128,
    Role='arn:aws:iam::XXXXXXX:role/LambdaFullAccess',
    Runtime='nodejs10.x',
    Timeout=3,
    DeadLetterConfig={

    },
    KMSKeyArn='',
    TracingConfig={
        'Mode': 'PassThrough'
    }
)
response = lambda_client.get_function_configuration(
    FunctionName='useast2afterdeleting'
)
response = lambda_client.get_function(
    FunctionName='useast2afterdeleting'
)
response = lambda_client.list_tags(
)

iam_client = boto3.client('iam', region_name='us-east-2')

response = iam_client.get_role(
    RoleName='LambdaFullAccess'
)

kms_client = boto3.client('kms', region_name='us-east-2')

response = kms_client.list_keys()
response = iam_client.list_roles()

ec2_client = boto3.client('ec2', region_name='us-east-2')

response = ec2_client.describe_vpcs()
response = lambda_client.create_function(
    Code={
        'ZipFile': 'UEsDBAoAAAAIAKwF504/MdkflAAAAL4AAAAIAAAAaW5kZXguanM9TcsKgkAU3fsVt5UKodJSsU0tIiIX9QOjc62BecjcayTRvzcpeDbncB4cfA/OM2VPYaVGDzUImmwHCb7Qcgr1Hj4RBOQ53JtjA8oMGk3IZrdzlhg80hAEhvVS/oNY8EgHJ7GEXVFs16B1cirhfGuuGbFX9qH6KYlPqLWD3jsDF2FaKTZxumy+1UweefR2/aqi4P8AUEsBAh4DCgAAAAgArAXnTj8x2R+UAAAAvgAAAAgAAAAAAAAAAAAAALSBAAAAAGluZGV4LmpzUEsFBgAAAAABAAEANgAAALoAAAAAAA=='
    },
    Description='',
    FunctionName='**lambdalondonregion**',
    Handler='index.handler',
    MemorySize=128,
    Role='arn:aws:iam::XXXXXXX:role/LambdaFullAccess',
    Runtime='nodejs10.x',
    Timeout=3,
    DeadLetterConfig={

    },
    KMSKeyArn='',
    TracingConfig={
        'Mode': 'PassThrough'
    }
)
response = lambda_client.get_function_configuration(
    FunctionName='lambdalondonregion'
)
response = lambda_client.get_function(
    FunctionName='lambdalondonregion'
)
response = lambda_client.list_tags(
)
response = iam_client.get_role(
    RoleName='LambdaFullAccess'
)
response = kms_client.list_keys()
response = iam_client.list_roles()
response = ec2_client.describe_vpcs()
response = lambda_client.create_function(
    Code={
        'ZipFile': 'UEsDBAoAAAAIAPgF504/MdkflAAAAL4AAAAIAAAAaW5kZXguanM9TcsKgkAU3fsVt5UKodJSsU0tIiIX9QOjc62BecjcayTRvzcpeDbncB4cfA/OM2VPYaVGDzUImmwHCb7Qcgr1Hj4RBOQ53JtjA8oMGk3IZrdzlhg80hAEhvVS/oNY8EgHJ7GEXVFs16B1cirhfGuuGbFX9qH6KYlPqLWD3jsDF2FaKTZxumy+1UweefR2/aqi4P8AUEsBAh4DCgAAAAgA+AXnTj8x2R+UAAAAvgAAAAgAAAAAAAAAAAAAALSBAAAAAGluZGV4LmpzUEsFBgAAAAABAAEANgAAALoAAAAAAA=='
    },
    Description='',
    FunctionName='**apsoutheast2region**',
    Handler='index.handler',
    MemorySize=128,
    Role='arn:aws:iam::XXXXXXX:role/LambdaFullAccess',
    Runtime='nodejs10.x',
    Timeout=3,
    DeadLetterConfig={

    },
    KMSKeyArn='',
    TracingConfig={
        'Mode': 'PassThrough'
    }
)
response = kms_client.list_keys()
response = iam_client.list_roles()
response = ec2_client.describe_vpcs()
response = lambda_client.get_function_configuration(
    FunctionName='apsoutheast2region'
)
response = lambda_client.get_function(
    FunctionName='apsoutheast2region'
)
response = lambda_client.list_tags(
)
response = iam_client.get_role(
    RoleName='LambdaFullAccess'
)
response = kms_client.list_keys()
response = iam_client.list_roles()
response = ec2_client.describe_vpcs()```
iann0036 commented 5 years ago

Thanks Rahul,

The behaviour seems inconsistent. I tested myself in Canada Central and got 3 failures before a 200 success. It's an eventual consistency problem with the created IAM role.

console

My only conflict is in the premise of the issue. Technically, the console is attempting the create_function call a number of times, so Console Recorder is replicating that.

Also, the lack of clearing previous recordings is intentional. This is to facilitate aggregate recordings whilst pausing the recording state in between wanted actions.

PenelopeFudd commented 4 years ago

I have the opposite problem; Console Recorder isn't recording any lambda function creation calls. :-/

If I go to a Lambda function, start recording, make a change in the code, or perhaps just the description, click save, then view the console log, it says:

# No recorded actions yet

I've tried clearing the console, starting and stopping recording, all to no avail. I have realized that I need to close and reopen the console to see additional calls, and the calls that load the lambda console are showing up.

Any ideas?