Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cloudformation_starter: Unable to extract id #2179

Closed
@jhaood

Description

@jhaood

LocalStack v0.10.8 fails to retrieve the CloudFormation stack after it successfully deployed the stack. The DEBUG output shows LS creating the CFN stack. The CFN template creates an IAM::Role. But then LS fails with "Unable to extract id" and then LS fails with a ValidationError. LocalStack correctly created the IAM::Role and the command-line "aws --endpoint... cloudformation list-roles" returns the role.

It looks like there's a bug in cloudformation_starter.py:299 where it's looking for a lower-case "id" but the next line parses "RoleId" from the response. The absence of "id" causes the error "Unable to extract id for resource" on line 307.

Here's the response that LS expects to find an "id". (Sorry about the terrible formatting)

{
  'Role': {
    'Path': '/',
    'RoleName': '2020-03-17',
    'RoleId': 'a4cu43jwuhoqmqcbibfe',
    'Arn': 'arn:aws:iam::000000000000:role/2020-03-17',
    'CreateDate': datetime.datetime(2020, 3, 17, 19, 21, 22, 805000, tzinfo=tzlocal()),
    'AssumeRolePolicyDocument': {
      'Statement': [
        {
          'Action': '*:*',
          'Effect': 'Allow',
          'Principal': {
            'Service': '*'
          },
          'Sid': 'SuperRole'
        }
      ],
      'Version': '2008-10-17'
    },
    'MaxSessionDuration': 3600
  },
  'ResponseMetadata': {
    'RequestId': '4a93ceee-9966-11e1-b624-b1aEXAMPLE7c',
    'HTTPStatusCode': 200,
    'HTTPHeaders': {
      'server': 'BaseHTTP/0.6 Python/3.8.2',
      'date': 'Tue, 17 Mar 2020 19:21:22 GMT',
      'content-type': 'text/html; charset=utf-8',
      'content-length': '647',
      'access-control-allow-origin': '*',
      'access-control-allow-methods': 'HEAD,GET,PUT,POST,DELETE,OPTIONS,PATCH',
      'access-control-allow-headers': 'authorization,content-type,content-md5,cache-control,x-amz-content-sha256,x-amz-date,x-amz-security-token,x-amz-user-agent,x-amz-target,x-amz-acl,x-amz-version-id,x-localstack-target,x-amz-tagging',
      'access-control-expose-headers': 'x-amz-version-id'
    },
    'RetryAttempts': 0
  }
}

Here's the DEBUG log:

> 
CFN error: 

2020-03-17T19:21:17:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "DescribeStacks" (400) POST /: b'<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">\n  <Error>\n    <Type>Sender</Type>\n    <Code>ValidationError</Code>\n    <Message>Stack with id arn:aws:cloudformation:us-east-1:000000000000:stack/AdskCfnAdministratorAccessExecutionRole/1c837ed6-95fb-4095-8608-8fa04a23b3e8 does not exist</Message>\n  </Error>\n  <RequestId>cf4c737e-5ae2-11e4-a7c9-ad44eEXAMPLE</RequestId>\n</ErrorResponse>'
2020-03-17T19:21:22:DEBUG:localstack.services.cloudformation.cloudformation_starter: Currently processing stack resource AdskCfnAdministratorAccessExecutionRole/AdskCfnAdministratorAccessExecutionRole: False
2020-03-17T19:21:22:DEBUG:localstack.services.cloudformation.cloudformation_starter: Deploying CloudFormation resource (update=False, exists=False, updateable=False): {'Properties': {'AssumeRolePolicyDocument': {'Statement': [{'Action': '*:*', 'Effect': 'Allow', 'Principal': {'Service': '*'}, 'Sid': 'SuperRole'}], 'Version': '2008-10-17'}, 'RoleName': '2020-03-17'}, 'Type': 'AWS::IAM::Role'}
2020-03-17T19:21:22:DEBUG:localstack.utils.cloudformation.template_deployer: Running action "create" for resource type "IAM::Role" id "AdskCfnAdministratorAccessExecutionRole"
2020-03-17T19:21:22:DEBUG:localstack.utils.cloudformation.template_deployer: Request for resource type "IAM::Role" in region us-west-2: create_role {'AssumeRolePolicyDocument': '{"Statement": [{"Action": "*:*", "Effect": "Allow", "Principal": {"Service": "*"}, "Sid": "SuperRole"}], "Version": "2008-10-17"}', 'RoleName': '2020-03-17'}
2020-03-17T19:21:22:DEBUG:localstack.services.cloudformation.cloudformation_starter: Updating resource id: q0duo3irgfczab3p7504 - None, <moto.iam.models.Role object at 0x7f3e600f95b0> - {'Properties': {'AssumeRolePolicyDocument': {'Statement': [{'Action': '*:*', 'Effect': 'Allow', 'Principal': {'Service': '*'}, 'Sid': 'SuperRole'}], 'Version': '2008-10-17'}, 'RoleName': '2020-03-17'}, 'Type': 'AWS::IAM::Role'}
2020-03-17T19:21:22:WARNING:localstack.services.cloudformation.cloudformation_starter: Unable to extract id for resource AdskCfnAdministratorAccessExecutionRole: {'Role': {'Path': '/', 'RoleName': '2020-03-17', 'RoleId': 'a4cu43jwuhoqmqcbibfe', 'Arn': 'arn:aws:iam::000000000000:role/2020-03-17', 'CreateDate': datetime.datetime(2020, 3, 17, 19, 21, 22, 805000, tzinfo=tzlocal()), 'AssumeRolePolicyDocument': {'Statement': [{'Action': '*:*', 'Effect': 'Allow', 'Principal': {'Service': '*'}, 'Sid': 'SuperRole'}], 'Version': '2008-10-17'}, 'MaxSessionDuration': 3600}, 'ResponseMetadata': {'RequestId': '4a93ceee-9966-11e1-b624-b1aEXAMPLE7c', 'HTTPStatusCode': 200, 'HTTPHeaders': {'server': 'BaseHTTP/0.6 Python/3.8.2', 'date': 'Tue, 17 Mar 2020 19:21:22 GMT', 'content-type': 'text/html; charset=utf-8', 'content-length': '647', 'access-control-allow-origin': '*', 'access-control-allow-methods': 'HEAD,GET,PUT,POST,DELETE,OPTIONS,PATCH', 'access-control-allow-headers': 'authorization,content-type,content-md5,cache-control,x-amz-content-sha256,x-amz-date,x-amz-security-token,x-amz-user-agent,x-amz-target,x-amz-acl,x-amz-version-id,x-localstack-target,x-amz-tagging', 'access-control-expose-headers': 'x-amz-version-id'}, 'RetryAttempts': 0}}
2020-03-17T19:21:22:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "DescribeStacks" (400) POST /: b'<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">\n  <Error>\n    <Type>Sender</Type>\n    <Code>ValidationError</Code>\n    <Message>Stack with id arn:aws:cloudformation:us-east-1:000000000000:stack/AdskCfnAdministratorAccessExecutionRole/d696a1db-1f6d-4c59-af82-3a667680851c does not exist</Message>\n  </Error>\n  <RequestId>cf4c737e-5ae2-11e4-a7c9-ad44eEXAMPLE</RequestId>\n</ErrorResponse>'
2020-03-17T19:26:30:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "GetTemplate" (500) POST /: b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>500 Internal Server Error</title>\n<h1>Internal Server Error</h1>\n<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>\n'
$ aws --endpoint-url=http://localhost:4581 cloudformation describe-stacks
{
    "Stacks": [
        {
            "StackId": "arn:aws:cloudformation:us-east-1:000000000000:stack/AdskCfnAdministratorAccessExecutionRole/1c837ed6-95fb-4095-8608-8fa04a23b3e8",
            "StackName": "AdskCfnAdministratorAccessExecutionRole",
            "Parameters": [],
            "CreationTime": "2010-07-27T22:28:28Z",
            "StackStatus": "CREATE_COMPLETE",
            "DisableRollback": false,
            "NotificationARNs": [],
            "Outputs": [
                {
                    "OutputKey": "RoleReference",
                    "OutputValue": "y7v7ml1dqoe681unaqef"
                },
                {
                    "OutputKey": "RoleArn",
                    "OutputValue": "arn:aws:iam::000000000000:role/AdskCfnAdministratorAccessExecutionRole-AdskCfnAdministratorAccessExecutionRole-CLYEWPKI2CBA"
                }
            ],
            "Tags": []
        },
        {
            "StackId": "arn:aws:cloudformation:us-east-1:000000000000:stack/AdskCfnAdministratorAccessExecutionRole/d696a1db-1f6d-4c59-af82-3a667680851c",
            "StackName": "AdskCfnAdministratorAccessExecutionRole",
            "Parameters": [],
            "CreationTime": "2010-07-27T22:28:28Z",
            "StackStatus": "CREATE_COMPLETE",
            "DisableRollback": false,
            "NotificationARNs": [],
            "Outputs": [
                {
                    "OutputKey": "RoleArn",
                    "OutputValue": "arn:aws:iam::000000000000:role/AdskCfnAdministratorAccessExecutionRole-AdskCfnAdministratorAccessExecutionRole-SFBCD11W3JFN"
                },
                {
                    "OutputKey": "RoleReference",
                    "OutputValue": "q0duo3irgfczab3p7504"
                }
            ],
            "Tags": []
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions