import boto3 import os import json ...

问题描述 投票:0回答:1
i got the answer to problem.There is one property associated with EMR cluster VisibleToAllUsers. When we spin our EMR cluster using CLoudformation script it's default value is set which is false. So that's why EMR id was not valid. SO the solution for it is to make the VisibleToAllUsers property to true than other IAM can also view the EMR cluster and than the script and lambda function works correctly.
Resources:
  LFTULJ:
    Type: 'AWS::Lambda::Function'
    Properties:
      Runtime: python3.6
      Code:
        ZipFile: |
          import boto3
          import os
          import json

          stack_name = os.environ['stackName']

          def delete_cfn(stack_name):
              try:
                  cfn = boto3.resource('cloudformation')
                  stack = cfn.Stack(stack_name)
                  stack.delete()
                  return "SUCCESS"
              except:
                  return "ERROR"

          def handler(event,context):
              print("Received event:")
              print(json.dumps(event))
              return delete_cfn(stack_name)

      Handler: index.handler
      Environment: 
        Variables: 
          stackName: shubham
      Role: 'arn:aws:iam::261598744157:role/terminate'
      Timeout: '60'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 20d06512-220b-4ef6-b56a-f65d2a0c49d4

Cluster id 'j-AQ1M94XKWDDJP' is not valid. (Service: AmazonElasticMapReduce; Status Code: 400; Error Code: InvalidRequestException; Request ID: 0283892f-c5aa-440d-968a-8cfb4585fe23)我正在使用lambda函数删除堆栈。所有的东西都被删除了,但是EMR集群没有终止。显示的错误是

而具有该ID的集群存在。
amazon-web-services amazon-cloudformation amazon-emr
1个回答
1
投票

资源。LFTULJ: 类型:"AWS::Lambda::Function 'AWS::Lambda::Function' 属性。Runtime: python3.6 Code: ZipFile。

© www.soinside.com 2019 - 2024. All rights reserved.