AWS Organization Unit
Usage
New Organization Unit from root organization
To create a new AWS Organization Unit, use the OrganizationUnit Construct provided.
| import { Construct } from 'constructs';
import { Organization, OrganizationUnit } from '@jttc/aws-organizations';
export class OrganizationStack extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
const organization = new Organization(this, 'Organization');
new OrganizationUnit(this, 'WorkloadsOrganizationUnit', {
organizationUnitName: 'workloads',
parent: organization,
});
}
}
|
New Organization Unit from belongs to other Organization Unit
To create a new AWS Organization Unit which belongs to other Organization Unit.
| import { Construct } from 'constructs';
import { Organization, OrganizationUnit } from '@jttc/aws-organizations';
export class OrganizationStack extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
const organization = new Organization(this, 'Organization');
const workloadsOrganizationUnit = new OrganizationUnit(
this,
'WorkloadsOrganizationUnit',
{
organizationUnitName: 'workloads',
parent: organization,
}
);
new OrganizationUnit(this, 'ProdOrganizationUnit', {
organizationUnitName: 'Prod',
parent: workloadsOrganizationUnit,
});
}
}
|
Existing organization
The construct provides a method to import a organization unit from existing one
| import { Construct } from 'constructs';
import { OrganizationUnit } from '@jttc/aws-organizations';
export class OrganizationStack extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
const organizationUnit = OrganizationUnit.fromOrganizationUnitAttributes(
this,
'OrganizationUnit',
{
organizationUnitId: 'ou-84uhd9',
organizationUnitName: 'worloads',
organizationUnitArn:
'arn:aws:organizations::123456789012:ou/o-74975/ou-84uhd9',
}
);
}
}
|