

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 中斷 Infrastructure Composer 中的卡片連線
<a name="reference-navigation-gestures-disconnect"></a>

在 Infrastructure Composer 中，您可以使用*增強型元件卡*和*標準元件卡*來連接和中斷連接 AWS 資源。本節說明如何中斷這兩種卡片類型的連線。

## 增強型元件卡
<a name="using-composer-connecting-enhanced-disconnect"></a>

若要中斷連線增強型元件卡，請選取該行，然後選擇**中斷連線**。

![\[正在從 Lambda 函數中斷連線的 API Gateway 卡。\]](http://docs.aws.amazon.com/zh_tw/infrastructure-composer/latest/dg/images/aac_use_con_03.png)


Infrastructure Composer 將自動修改您的範本，以從您的應用程式移除事件驅動關係。

## 標準元件卡
<a name="w2aac17c31b7"></a>

標準元件卡不包含用於建立與其他資源連線的連接埠。在[卡片組態](using-composer-standard-cards.md)期間，您可以在應用程式的範本中指定事件驅動關係， Infrastructure Composer 會自動偵測這些連線，並在卡片之間使用虛線將其視覺化。若要中斷連接標準元件卡，請移除應用程式範本中的事件驅動關係。

下列範例顯示與 Amazon API Gateway 靜態 API 連線的 Lambda 函數：

```
AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyApi:
    Type: 'AWS::ApiGateway::RestApi'
    Properties:
      Name: MyApi

  ApiGatewayMethod:
    Type: 'AWS::ApiGateway::Method'
    Properties:
      HttpMethod: POST  # Specify the HTTP method you want to use (e.g., GET, POST, PUT, DELETE)
      ResourceId: !GetAtt MyApi.RootResourceId
      RestApiId: !Ref MyApi
      AuthorizationType: NONE
      Integration:
        Type: AWS_PROXY
        IntegrationHttpMethod: POST
        Uri: !Sub
          - arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${LambdaFunctionArn}/invocations
          - { LambdaFunctionArn: !GetAtt MyLambdaFunction.Arn }
      MethodResponses:
        - StatusCode: 200

  MyLambdaFunction:
    Type: 'AWS::Lambda::Function'
    Properties:
      Handler: index.handler
      Role: !GetAtt LambdaExecutionRole.Arn
      Runtime: nodejs14.x
      Code:
        S3Bucket: your-bucket-name
        S3Key: your-lambda-zip-file.zip

  LambdaExecutionRole:
    Type: 'AWS::IAM::Role'
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service: lambda.amazonaws.com
            Action: 'sts:AssumeRole'
      Policies:
        - PolicyName: LambdaExecutionPolicy
          PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Effect: Allow
                Action:
                  - 'logs:CreateLogGroup'
                  - 'logs:CreateLogStream'
                  - 'logs:PutLogEvents'
                Resource: 'arn:aws:logs:*:*:*'
              - Effect: Allow
                Action:
                  - 'lambda:InvokeFunction'
                Resource: !GetAtt MyLambdaFunction.Arn
```

若要移除兩張卡片之間的連線，請移除在 `ApiGatewayMethod:`下`MyLambdaFunction`列出的 參考`Integration`。