> **Experimental**
>
> `@aws-cdk/aws-servicecatalogappregistry-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# ApplicationAssociator

Construct · [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)

An AppRegistry construct to automatically create an application with the given name and description.

The application name must be unique at the account level per region and it's immutable.
This construct will automatically associate all stacks in the given scope, however
in case of a `Pipeline` stack, stage underneath the pipeline will not automatically be associated and
needs to be associated separately.

If cross account stack is detected and `associateCrossAccountStacks` in `TargetApplicationOptions` is `true`,
then the application will automatically be shared with the consumer accounts to allow associations.
Otherwise, the application will not be shared.
Cross account feature will only work for non environment agnostic stacks.

Extends: [Construct](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Construct.html) › ApplicationAssociator
Implements: [IConstruct](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.IConstruct.html), [IDependable](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.IDependable.html)

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`lib/application-associator.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-servicecatalogappregistry-alpha/lib/application-associator.ts#L33)

## Example

TypeScript:

```ts
import * as cdk from "aws-cdk-lib";

const app = new App();

const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplication', {
  applications: [appreg.TargetApplication.createApplicationStack({
    applicationName: 'MyAssociatedApplication',
    // 'Application containing stacks deployed via CDK.' is the default
    applicationDescription: 'Associated Application description',
    stackName: 'MyAssociatedApplicationStack',
    // AWS Account and Region that are implied by the current CLI configuration is the default
    env: { account: '123456789012', region: 'us-east-1' },
  })],
});

// Associate application to the attribute group.
associatedApp.appRegistryApplication.addAttributeGroup('MyAttributeGroup' , {
  attributeGroupName: 'MyAttributeGroupName',
  description: 'Test attribute group',
  attributes: {},
});
```

Python:

```python
import aws_cdk as cdk

app = App()

associated_app = appreg.ApplicationAssociator(app, "AssociatedApplication",
    applications=[appreg.TargetApplication.create_application_stack(
        application_name="MyAssociatedApplication",
        # 'Application containing stacks deployed via CDK.' is the default
        application_description="Associated Application description",
        stack_name="MyAssociatedApplicationStack",
        # AWS Account and Region that are implied by the current CLI configuration is the default
        env=cdk.Environment(account="123456789012", region="us-east-1")
    )]
)

# Associate application to the attribute group.
associated_app.app_registry_application.add_attribute_group("MyAttributeGroup",
    attribute_group_name="MyAttributeGroupName",
    description="Test attribute group",
    attributes={}
)
```

Java:

```java
import software.amazon.awscdk.*;

App app = new App();

ApplicationAssociator associatedApp = ApplicationAssociator.Builder.create(app, "AssociatedApplication")
        .applications(List.of(TargetApplication.createApplicationStack(CreateTargetApplicationOptions.builder()
                .applicationName("MyAssociatedApplication")
                // 'Application containing stacks deployed via CDK.' is the default
                .applicationDescription("Associated Application description")
                .stackName("MyAssociatedApplicationStack")
                // AWS Account and Region that are implied by the current CLI configuration is the default
                .env(Environment.builder().account("123456789012").region("us-east-1").build())
                .build())))
        .build();

// Associate application to the attribute group.
associatedApp.appRegistryApplication.addAttributeGroup("MyAttributeGroup", AttributeGroupAssociationProps.builder()
        .attributeGroupName("MyAttributeGroupName")
        .description("Test attribute group")
        .attributes(Map.of())
        .build());
```

C#:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.ServiceCatalogAppRegistry.Alpha
using Amazon.CDK;

var app = new App();

var associatedApp = new ApplicationAssociator(app, "AssociatedApplication", new ApplicationAssociatorProps {
    Applications = new [] { TargetApplication.CreateApplicationStack(new CreateTargetApplicationOptions {
        ApplicationName = "MyAssociatedApplication",
        // 'Application containing stacks deployed via CDK.' is the default
        ApplicationDescription = "Associated Application description",
        StackName = "MyAssociatedApplicationStack",
        // AWS Account and Region that are implied by the current CLI configuration is the default
        Env = new Environment { Account = "123456789012", Region = "us-east-1" }
    }) }
});

// Associate application to the attribute group.
associatedApp.AppRegistryApplication.AddAttributeGroup("MyAttributeGroup", new AttributeGroupAssociationProps {
    AttributeGroupName = "MyAttributeGroupName",
    Description = "Test attribute group",
    Attributes = new Dictionary<string, object> { }
});
```

Go:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkservicecatalogappregistryalpha/v2
import cdk "github.com/aws/aws-cdk-go/awscdk"

app := awscdk.NewApp()

associatedApp := appreg.NewApplicationAssociator(app, jsii.String("AssociatedApplication"), &ApplicationAssociatorProps{
	Applications: []TargetApplication{
		appreg.TargetApplication_CreateApplicationStack(&CreateTargetApplicationOptions{
			ApplicationName: jsii.String("MyAssociatedApplication"),
			// 'Application containing stacks deployed via CDK.' is the default
			ApplicationDescription: jsii.String("Associated Application description"),
			StackName: jsii.String("MyAssociatedApplicationStack"),
			// AWS Account and Region that are implied by the current CLI configuration is the default
			Env: &Environment{
				Account: jsii.String("123456789012"),
				Region: jsii.String("us-east-1"),
			},
		}),
	},
})

// Associate application to the attribute group.
associatedApp.appRegistryApplication.AddAttributeGroup(jsii.String("MyAttributeGroup"), &AttributeGroupAssociationProps{
	AttributeGroupName: jsii.String("MyAttributeGroupName"),
	Description: jsii.String("Test attribute group"),
	Attributes: map[string]interface{}{
	},
})
```

## Initializer

TypeScript:

```ts
new ApplicationAssociator(scope: App, id: string, props: ApplicationAssociatorProps)
```

Python:

```python
ApplicationAssociator(scope: App, id: str, props: ApplicationAssociatorProps)
```

Java:

```java
new ApplicationAssociator(App scope, String id, ApplicationAssociatorProps props)
```

C#:

```csharp
new ApplicationAssociator(App scope, string id, ApplicationAssociatorProps props)
```

Go:

```go
NewApplicationAssociator(Scope App, Id *string, Props ApplicationAssociatorProps)
```

## Construct Props

- `applications`: [TargetApplication](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-servicecatalogappregistry-alpha.TargetApplication.html)[] (required) — Application associator properties.

  **Default:** Empty array.

## Properties

- `appRegistryApplication`: [IApplication](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-servicecatalogappregistry-alpha.IApplication.html) — Get the AppRegistry application.

- `node`: [Node](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Node.html) — The tree node.

## Methods

- `associateStage(stage: Stage): Stage` — Associate this application with the given stage.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isStageAssociated(stage: Stage): boolean` — Validates if a stage is already associated to the application.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
