# StageAttributes

The attributes of an imported Stage.

Used as argument in: [Stage.fromStageAttributes](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.Stage.html#fromstageattributes)

- Source: [`aws-apigateway/lib/stage.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigateway/lib/stage.ts#L218)
- Type last changed: v2.46.0 · 13 Oct 2022

## Example

TypeScript:

```ts
declare const restApi: apigateway.IRestApi;
const importedStage = apigateway.Stage.fromStageAttributes(this, 'imported-stage', {
  stageName: 'myStageName',
  restApi,
});

importedStage.addApiKey('MyApiKey');
```

Python:

```python
# rest_api: apigateway.IRestApi

imported_stage = apigateway.Stage.from_stage_attributes(self, "imported-stage",
    stage_name="myStageName",
    rest_api=rest_api
)

imported_stage.add_api_key("MyApiKey")
```

Java:

```java
IRestApi restApi;

IStage importedStage = Stage.fromStageAttributes(this, "imported-stage", StageAttributes.builder()
        .stageName("myStageName")
        .restApi(restApi)
        .build());

importedStage.addApiKey("MyApiKey");
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
IRestApi restApi;

var importedStage = Stage.FromStageAttributes(this, "imported-stage", new StageAttributes {
    StageName = "myStageName",
    RestApi = restApi
});

importedStage.AddApiKey("MyApiKey");
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var restApi IRestApi

importedStage := apigateway.Stage_FromStageAttributes(this, jsii.String("imported-stage"), &StageAttributes{
	StageName: jsii.String("myStageName"),
	RestApi: RestApi,
})

importedStage.AddApiKey(jsii.String("MyApiKey"))
```

## Properties

- `restApi`: [IRestApi](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.IRestApi.html) (required) — The RestApi that the stage belongs to.

- `stageName`: string (required) — The name of the stage.
