

サポート終了通知: 2026 年 10 月 7 日に、 AWS はサポートを終了します AWS Proton。2026 年 10 月 7 日以降、 AWS Proton コンソールまたは AWS Proton リソースにアクセスできなくなります。デプロイされたインフラストラクチャはそのまま残ります。詳細については、[AWS Proton 「サービス廃止と移行ガイド](https://docs.aws.amazon.com/proton/latest/userguide/proton-end-of-support.html)」を参照してください。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 環境 CloudFormation IaC ファイルパラメータの詳細と例
<a name="env-parameters"></a>

あなたの環境 infrastructure as code (IaC) ファイルでパラメータを定義し、参照することができます。 AWS Proton パラメータ、パラメータタイプ、パラメータ名前空間、および IaC ファイルでパラメータを使用する方法の詳細については、「」を参照してください[AWS Proton パラメータ](parameters.md)。

## 環境パラメータを定義する
<a name="env-parameters.define"></a>

環境 IaC ファイルの入力パラメータと出力パラメータの両方を定義できます。
+ **入力パラメータ** — あなたの [スキーマファイル](ag-schema.md)に環境入力パラメータを定義します。

  以下に挙げるのは、一般的なユースケースの入力パラメータの例です。
  + VPC CIDR 値
  + ロードバランサーの設定
  + データベース設定
  + ヘルスチェックのタイムアウト

  管理者は[環境を作成する](ag-create-env.md)ときに、入力パラメータの値を指定できます。
  + コンソールを使用して、 AWS Proton が提供するスキーマベースのフォームに入力します。
  + 値が含まれる仕様は CLI で指定します。
+ **出力パラメータ** — あなたの環境 IaC ファイルで環境出力を定義します。その後、他のリソースの IaC ファイルでこれらの出力を参照できます。

## 環境 IaC ファイルのパラメータ値を読み取ります。
<a name="env-parameters.refer"></a>

環境 IaC ファイル内の環境に関連するパラメータは読み取ることができます。パラメータ値を読み取るには、 AWS Proton パラメータ名前空間でパラメータの名前を参照します。
+ **入力パラメータ** — `environment.inputs.input-name` を参照して環境入力値を読み取ります。
+ **リソースパラメータ** – などの名前を参照して AWS Proton リソースパラメータを読み取ります`environment.name`。

**注記**  
他のリソースの出力パラメータは、環境 IaC ファイルでは利用できません。

## 環境とパラメータのあるサービス IaC ファイルの例
<a name="env-parameters.example"></a>

以下の例は、環境 IaC ファイルにおけるパラメータ定義と参照です。以下の例では、次に、環境 IaC ファイルで定義されている環境出力パラメータをサービス IaC ファイルで参照する方法を示します。

**Example 環境 CloudFormation IaC ファイル**  
この例では、以下の点に注意してください。  
+ `environment.inputs.` 名前空間は環境入力パラメータを参照します。
+ Amazon EC2 Systems Manager (SSM) パラメータ `StoreInputValue` は、環境入力を連結します。
+ `MyEnvParameterValue` 出力には、出力パラメータと同じ入力パラメータ連結が表示されます。さらに 3 つの出力パラメータによって、入力パラメータが個別に公開されます。
+ さらに 6 つの出力パラメータで、環境がプロビジョニングするリソースが公開されます。

```
Resources:
  StoreInputValue:
    Type: AWS::SSM::Parameter
    Properties:
      Type: String
      Value: "{{ environment.inputs.my_sample_input }} {{ environment.inputs.my_other_sample_input}} {{ environment.inputs.another_optional_input }}"
              # input parameter references

# These output values are available to service infrastructure as code files as outputs, when given the 
# the 'environment.outputs' namespace, for example, service_instance.environment.outputs.ClusterName.
Outputs:
  MyEnvParameterValue:                                        # output definition
    Value: !GetAtt StoreInputValue.Value
  MySampleInputValue:                                         # output definition
    Value: "{{ environment.inputs.my_sample_input }}"         #   input parameter reference
  MyOtherSampleInputValue:                                    # output definition
    Value: "{{ environment.inputs.my_other_sample_input }}"   #   input parameter reference
  AnotherOptionalInputValue:                                  # output definition
    Value: "{{ environment.inputs.another_optional_input }}"  #   input parameter reference
  ClusterName:                                                # output definition
    Description: The name of the ECS cluster
    Value: !Ref 'ECSCluster'                                  #   provisioned resource
  ECSTaskExecutionRole:                                       # output definition
    Description: The ARN of the ECS role
    Value: !GetAtt 'ECSTaskExecutionRole.Arn'                 #   provisioned resource
  VpcId:                                                      # output definition
    Description: The ID of the VPC that this stack is deployed in
    Value: !Ref 'VPC'                                         #   provisioned resource
  PublicSubnetOne:                                            # output definition
    Description: Public subnet one
    Value: !Ref 'PublicSubnetOne'                             #   provisioned resource
  PublicSubnetTwo:                                            # output definition
    Description: Public subnet two
    Value: !Ref 'PublicSubnetTwo'                             #   provisioned resource
  ContainerSecurityGroup:                                     # output definition
    Description: A security group used to allow Fargate containers to receive traffic
    Value: !Ref 'ContainerSecurityGroup'                      #   provisioned resource
```

**Example サービス CloudFormation IaC ファイル**  
`environment.outputs.` 名前空間は、環境 IaC ファイルからの環境出力を参照します。たとえば、名前 `environment.outputs.ClusterName` は `ClusterName` 環境出力パラメータの値を読み取ります。  

```
AWSTemplateFormatVersion: '2010-09-09'
Description: Deploy a service on AWS Fargate, hosted in a public subnet, and accessible via a public load balancer.
Mappings:
  TaskSize:
    x-small:
      cpu: 256
      memory: 512
    small:
      cpu: 512
      memory: 1024
    medium:
      cpu: 1024
      memory: 2048
    large:
      cpu: 2048
      memory: 4096
    x-large:
      cpu: 4096
      memory: 8192
Resources:
  # A log group for storing the stdout logs from this service's containers
  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: '{{service_instance.name}}' # resource parameter

  # The task definition. This is a simple metadata description of what
  # container to run, and what resource requirements it has.
  TaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: '{{service_instance.name}}' # resource parameter
      Cpu: !FindInMap [TaskSize, {{service_instance.inputs.task_size}}, cpu] # input parameter
      Memory: !FindInMap [TaskSize, {{service_instance.inputs.task_size}}, memory] 
      NetworkMode: awsvpc
      RequiresCompatibilities:
        - FARGATE
      ExecutionRoleArn: '{{environment.outputs.ECSTaskExecutionRole}}'  # output reference to an environment infrastructure code file
      TaskRoleArn: !Ref "AWS::NoValue"
      ContainerDefinitions:
        - Name: '{{service_instance.name}}'  # resource parameter
          Cpu: !FindInMap [TaskSize, {{service_instance.inputs.task_size}}, cpu]
          Memory: !FindInMap [TaskSize, {{service_instance.inputs.task_size}}, memory]
          Image: '{{service_instance.inputs.image}}'
          PortMappings:
            - ContainerPort: '{{service_instance.inputs.port}}' # input parameter
          LogConfiguration:
            LogDriver: 'awslogs'
            Options:
              awslogs-group: '{{service_instance.name}}' # resource parameter
              awslogs-region: !Ref 'AWS::Region'
              awslogs-stream-prefix: '{{service_instance.name}}' # resource parameter

  # The service_instance. The service is a resource which allows you to run multiple
  # copies of a type of task, and gather up their logs and metrics, as well
  # as monitor the number of running tasks and replace any that have crashed
  Service:
    Type: AWS::ECS::Service
    DependsOn: LoadBalancerRule
    Properties:
      ServiceName: '{{service_instance.name}}'  # resource parameter
      Cluster: '{{environment.outputs.ClusterName}}' # output reference to an environment infrastructure as code file
      LaunchType: FARGATE
      DeploymentConfiguration:
        MaximumPercent: 200
        MinimumHealthyPercent: 75
      DesiredCount: '{{service_instance.inputs.desired_count}}'# input parameter
      NetworkConfiguration:
        AwsvpcConfiguration:
          AssignPublicIp: ENABLED
          SecurityGroups:
            - '{{environment.outputs.ContainerSecurityGroup}}' # output reference to an environment infrastructure as code file
          Subnets:
            - '{{environment.outputs.PublicSubnetOne}}' # output reference to an environment infrastructure as code file
            - '{{environment.outputs.PublicSubnetTwo}}' # output reference to an environment infrastructure as code file
      TaskDefinition: !Ref 'TaskDefinition'
      LoadBalancers:
        - ContainerName: '{{service_instance.name}}'  # resource parameter
          ContainerPort: '{{service_instance.inputs.port}}' # input parameter
          TargetGroupArn: !Ref 'TargetGroup'
[...]
```