

This is the new *Amazon CloudFormation Template Reference Guide*. Please update your bookmarks and links. For help getting started with CloudFormation, see the [Amazon CloudFormation User Guide](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/Welcome.html).

# AWS::AmplifyGen3::Environment

The `AWS::AmplifyGen3::Environment` resource specifies a custom environment of an Amazon Amplify Gen 3 app. Each environment has its own source configuration, IAM role, web hosting settings, and backend settings.

The production and preview environments that every app has are configured on the `AWS::AmplifyGen3::App` resource, not with this resource.

## Syntax
<a name="aws-resource-amplifygen3-environment-syntax"></a>

To declare this entity in your Amazon CloudFormation template, use the following syntax:

### JSON
<a name="aws-resource-amplifygen3-environment-syntax.json"></a>

```json
{
  "Type" : "AWS::AmplifyGen3::Environment",
  "Properties" : {
      "[AppName](#cfn-amplifygen3-environment-appname)" : {{String}},
      "[Backend](#cfn-amplifygen3-environment-backend)" : {{EnvironmentBackend}},
      "[EnvironmentName](#cfn-amplifygen3-environment-environmentname)" : {{String}},
      "[EnvironmentRoleArn](#cfn-amplifygen3-environment-environmentrolearn)" : {{String}},
      "[EnvironmentRolePermissionMode](#cfn-amplifygen3-environment-environmentrolepermissionmode)" : {{String}},
      "[EnvironmentVariables](#cfn-amplifygen3-environment-environmentvariables)" : {{[ EnvironmentVariable, ... ]}},
      "[GradualRolloutConfig](#cfn-amplifygen3-environment-gradualrolloutconfig)" : {{GradualRolloutConfig}},
      "[NetworkConfig](#cfn-amplifygen3-environment-networkconfig)" : {{NetworkConfig}},
      "[SourceConfig](#cfn-amplifygen3-environment-sourceconfig)" : {{EnvironmentSourceConfig}},
      "[Tags](#cfn-amplifygen3-environment-tags)" : {{[ Tag, ... ]}},
      "[WafLogConfigs](#cfn-amplifygen3-environment-waflogconfigs)" : {{[ WafLogConfig, ... ]}},
      "[Web](#cfn-amplifygen3-environment-web)" : {{EnvironmentWeb}}
    }
}
```

### YAML
<a name="aws-resource-amplifygen3-environment-syntax.yaml"></a>

```yaml
Type: AWS::AmplifyGen3::Environment
Properties:
  [AppName](#cfn-amplifygen3-environment-appname): {{String}}
  [Backend](#cfn-amplifygen3-environment-backend): {{
    EnvironmentBackend}}
  [EnvironmentName](#cfn-amplifygen3-environment-environmentname): {{String}}
  [EnvironmentRoleArn](#cfn-amplifygen3-environment-environmentrolearn): {{String}}
  [EnvironmentRolePermissionMode](#cfn-amplifygen3-environment-environmentrolepermissionmode): {{String}}
  [EnvironmentVariables](#cfn-amplifygen3-environment-environmentvariables): {{
    - EnvironmentVariable}}
  [GradualRolloutConfig](#cfn-amplifygen3-environment-gradualrolloutconfig): {{
    GradualRolloutConfig}}
  [NetworkConfig](#cfn-amplifygen3-environment-networkconfig): {{
    NetworkConfig}}
  [SourceConfig](#cfn-amplifygen3-environment-sourceconfig): {{
    EnvironmentSourceConfig}}
  [Tags](#cfn-amplifygen3-environment-tags): {{
    - Tag}}
  [WafLogConfigs](#cfn-amplifygen3-environment-waflogconfigs): {{
    - WafLogConfig}}
  [Web](#cfn-amplifygen3-environment-web): {{
    EnvironmentWeb}}
```

## Properties
<a name="aws-resource-amplifygen3-environment-properties"></a>

`AppName`  <a name="cfn-amplifygen3-environment-appname"></a>
The name of the app that the environment belongs to.  
*Required*: Yes  
*Type*: String  
*Minimum*: `1`  
*Maximum*: `40`  
*Update requires*: [Replacement](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`Backend`  <a name="cfn-amplifygen3-environment-backend"></a>
The backend settings for the environment.  
*Required*: No  
*Type*: [EnvironmentBackend](aws-properties-amplifygen3-environment-environmentbackend.md)  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`EnvironmentName`  <a name="cfn-amplifygen3-environment-environmentname"></a>
The name of the environment.  
*Required*: Yes  
*Type*: String  
*Minimum*: `1`  
*Maximum*: `40`  
*Update requires*: [Replacement](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`EnvironmentRoleArn`  <a name="cfn-amplifygen3-environment-environmentrolearn"></a>
The Amazon Resource Name (ARN) of the IAM role for the environment.  
*Required*: Yes  
*Type*: String  
*Minimum*: `20`  
*Maximum*: `2048`  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`EnvironmentRolePermissionMode`  <a name="cfn-amplifygen3-environment-environmentrolepermissionmode"></a>
The permission mode for the environment's IAM role.  
*Required*: No  
*Type*: String  
*Allowed values*: `SCOPED | FULL`  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`EnvironmentVariables`  <a name="cfn-amplifygen3-environment-environmentvariables"></a>
The environment variables for the environment. Changes take effect at the next deployment.  
*Required*: No  
*Type*: Array of [EnvironmentVariable](aws-properties-amplifygen3-environment-environmentvariable.md)  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`GradualRolloutConfig`  <a name="cfn-amplifygen3-environment-gradualrolloutconfig"></a>
The schedule that Amplify Gen 3 uses to shift traffic to a new deployment gradually.  
*Required*: No  
*Type*: [GradualRolloutConfig](aws-properties-amplifygen3-environment-gradualrolloutconfig.md)  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`NetworkConfig`  <a name="cfn-amplifygen3-environment-networkconfig"></a>
The VPC network configuration for the environment.  
*Required*: No  
*Type*: [NetworkConfig](aws-properties-amplifygen3-environment-networkconfig.md)  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`SourceConfig`  <a name="cfn-amplifygen3-environment-sourceconfig"></a>
The source configuration for the environment.  
*Required*: No  
*Type*: [EnvironmentSourceConfig](aws-properties-amplifygen3-environment-environmentsourceconfig.md)  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Tags`  <a name="cfn-amplifygen3-environment-tags"></a>
An array of key-value pairs to apply to this resource.  
For more information, see [Tag](https://docs.amazonaws.cn/AWSCloudFormation/latest/TemplateReference/aws-properties-resource-tags.html).  
*Required*: No  
*Type*: Array of [Tag](aws-properties-amplifygen3-environment-tag.md)  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`WafLogConfigs`  <a name="cfn-amplifygen3-environment-waflogconfigs"></a>
A list of the environment's Amazon WAF log configurations. Omitted when the environment has no WAF log configuration.  
*Required*: No  
*Type*: Array of [WafLogConfig](aws-properties-amplifygen3-environment-waflogconfig.md)  
*Minimum*: `1`  
*Maximum*: `1`  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Web`  <a name="cfn-amplifygen3-environment-web"></a>
The web hosting settings for the environment.  
*Required*: No  
*Type*: [EnvironmentWeb](aws-properties-amplifygen3-environment-environmentweb.md)  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

## Return values
<a name="aws-resource-amplifygen3-environment-return-values"></a>

### Ref
<a name="aws-resource-amplifygen3-environment-return-values-ref"></a>

When you pass the logical ID of this resource to the intrinsic `Ref` function, `Ref` returns the ARN of the environment.

For more information about using the `Ref` function, see [`Ref`](https://docs.amazonaws.cn/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html).

### Fn::GetAtt
<a name="aws-resource-amplifygen3-environment-return-values-fn--getatt"></a>

The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the `Fn::GetAtt` intrinsic function, see [`Fn::GetAtt`](https://docs.amazonaws.cn/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-getatt.html).

#### 
<a name="aws-resource-amplifygen3-environment-return-values-fn--getatt-fn--getatt"></a>

`Backend.DatabaseLogConfig.CloudWatchLogsConfig.LogGroupArn`  <a name="Backend.DatabaseLogConfig.CloudWatchLogsConfig.LogGroupArn-fn::getatt"></a>
The ARN of the Amazon CloudWatch Logs log group that receives the environment's database logs.

`CreatedAt`  <a name="CreatedAt-fn::getatt"></a>
The time at which the environment was created. The value is in ISO-8601 format.

`EnvironmentArn`  <a name="EnvironmentArn-fn::getatt"></a>
The Amazon Resource Name (ARN) of the environment.

`Type`  <a name="Type-fn::getatt"></a>
The type of the environment.

`Web.AccessLogConfig.CloudWatchLogsConfig.LogGroupArn`  <a name="Web.AccessLogConfig.CloudWatchLogsConfig.LogGroupArn-fn::getatt"></a>
The ARN of the Amazon CloudWatch Logs log group that receives the environment's access logs.

## Examples
<a name="aws-resource-amplifygen3-environment--examples"></a>

### Create a custom environment
<a name="aws-resource-amplifygen3-environment--examples--Create_a_custom_environment"></a>

The following example adds a staging environment to an existing app. The environment deploys pushes to the `staging` branch.

#### JSON
<a name="aws-resource-amplifygen3-environment--examples--Create_a_custom_environment--json"></a>

```json
{
    "Resources": {
        "StagingEnvironment": {
            "Type": "AWS::AmplifyGen3::Environment",
            "Properties": {
                "AppName": "my-app",
                "EnvironmentName": "staging",
                "EnvironmentRoleArn": "arn:aws:iam::123456789012:role/AmplifyGen3EnvironmentRole",
                "SourceConfig": {
                    "GitSource": {
                        "BranchMatchPatterns": [
                            "staging"
                        ]
                    }
                },
                "GradualRolloutConfig": {
                    "PresetConfig": {
                        "Preset": "ALL_AT_ONCE"
                    }
                }
            }
        }
    }
}
```

#### YAML
<a name="aws-resource-amplifygen3-environment--examples--Create_a_custom_environment--yaml"></a>

```yaml
Resources:
  StagingEnvironment:
    Type: AWS::AmplifyGen3::Environment
    Properties:
      AppName: my-app
      EnvironmentName: staging
      EnvironmentRoleArn: arn:aws:iam::123456789012:role/AmplifyGen3EnvironmentRole
      SourceConfig:
        GitSource:
          BranchMatchPatterns:
          - staging
      GradualRolloutConfig:
        PresetConfig:
          Preset: ALL_AT_ONCE
```