Class LaunchTemplateAttributes
Attributes for an imported LaunchTemplate.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class LaunchTemplateAttributes : ILaunchTemplateAttributes
Syntax (vb)
Public Class LaunchTemplateAttributes Implements ILaunchTemplateAttributes
Remarks
ExampleMetadata: infused
Examples
var distributionConfiguration = new DistributionConfiguration(this, "DistributionConfiguration", new DistributionConfigurationProps {
DistributionConfigurationName = "test-distribution-configuration",
Description = "A Distribution Configuration",
AmiDistributions = new [] { new AmiDistribution {
// Distribute AMI to us-east-2 and publish the AMI ID to an SSM parameter
Region = "us-east-2",
SsmParameters = new [] { new SSMParameterConfigurations {
Parameter = StringParameter.FromStringParameterAttributes(this, "CrossRegionParameter", new StringParameterAttributes {
ParameterName = "/imagebuilder/ami",
ForceDynamicReference = true
})
} }
} }
});
// For AMI-based image builds - add an AMI distribution in the current region
distributionConfiguration.AddAmiDistributions(new AmiDistribution {
AmiName = "imagebuilder-{{ imagebuilder:buildDate }}",
AmiDescription = "Build AMI",
AmiKmsKey = Key.FromLookup(this, "ComponentKey", new KeyLookupOptions { AliasName = "alias/distribution-encryption-key" }),
// Copy the AMI to different accounts
AmiTargetAccountIds = new [] { "123456789012", "098765432109" },
// Add launch permissions on the AMI
AmiLaunchPermission = new AmiLaunchPermission {
OrganizationArns = new [] { FormatArn(new ArnComponents { Region = "", Service = "organizations", Resource = "organization", ResourceName = "o-1234567abc" }) },
OrganizationalUnitArns = new [] { FormatArn(new ArnComponents {
Region = "",
Service = "organizations",
Resource = "ou",
ResourceName = "o-1234567abc/ou-a123-b4567890"
}) },
IsPublicUserGroup = true,
AccountIds = new [] { "234567890123" }
},
// Attach tags to the AMI
AmiTags = new Dictionary<string, string> {
{ "Environment", "production" },
{ "Version", "{{ imagebuilder:buildVersion }}" }
},
// Optional - publish the distributed AMI ID to an SSM parameter
SsmParameters = new [] { new SSMParameterConfigurations {
Parameter = StringParameter.FromStringParameterAttributes(this, "Parameter", new StringParameterAttributes {
ParameterName = "/imagebuilder/ami",
ForceDynamicReference = true
})
}, new SSMParameterConfigurations {
AmiAccount = "098765432109",
DataType = ParameterDataType.TEXT,
Parameter = StringParameter.FromStringParameterAttributes(this, "CrossAccountParameter", new StringParameterAttributes {
ParameterName = "imagebuilder-prod-ami",
ForceDynamicReference = true
})
} },
// Optional - create a new launch template version with the distributed AMI ID
LaunchTemplates = new [] { new LaunchTemplateConfiguration {
LaunchTemplate = LaunchTemplate.FromLaunchTemplateAttributes(this, "LaunchTemplate", new LaunchTemplateAttributes {
LaunchTemplateId = "lt-1234"
}),
SetDefaultVersion = true
}, new LaunchTemplateConfiguration {
AccountId = "123456789012",
LaunchTemplate = LaunchTemplate.FromLaunchTemplateAttributes(this, "CrossAccountLaunchTemplate", new LaunchTemplateAttributes {
LaunchTemplateId = "lt-5678"
}),
SetDefaultVersion = true
} },
// Optional - enable Fast Launch on an imported launch template
FastLaunchConfigurations = new [] { new FastLaunchConfiguration {
Enabled = true,
LaunchTemplate = LaunchTemplate.FromLaunchTemplateAttributes(this, "FastLaunchLT", new LaunchTemplateAttributes {
LaunchTemplateName = "fast-launch-lt"
}),
MaxParallelLaunches = 10,
TargetSnapshotCount = 2
} },
// Optional - license configurations to apply to the AMI
LicenseConfigurationArns = new [] { "arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-abcdefghijklmnopqrstuvwxyz" }
});
Synopsis
Constructors
| LaunchTemplateAttributes() | Attributes for an imported LaunchTemplate. |
Properties
| LaunchTemplateId | The identifier of the Launch Template. |
| LaunchTemplateName | The name of the Launch Template. |
| VersionNumber | The version number of this launch template to use. |
Constructors
LaunchTemplateAttributes()
Attributes for an imported LaunchTemplate.
public LaunchTemplateAttributes()
Remarks
ExampleMetadata: infused
Examples
var distributionConfiguration = new DistributionConfiguration(this, "DistributionConfiguration", new DistributionConfigurationProps {
DistributionConfigurationName = "test-distribution-configuration",
Description = "A Distribution Configuration",
AmiDistributions = new [] { new AmiDistribution {
// Distribute AMI to us-east-2 and publish the AMI ID to an SSM parameter
Region = "us-east-2",
SsmParameters = new [] { new SSMParameterConfigurations {
Parameter = StringParameter.FromStringParameterAttributes(this, "CrossRegionParameter", new StringParameterAttributes {
ParameterName = "/imagebuilder/ami",
ForceDynamicReference = true
})
} }
} }
});
// For AMI-based image builds - add an AMI distribution in the current region
distributionConfiguration.AddAmiDistributions(new AmiDistribution {
AmiName = "imagebuilder-{{ imagebuilder:buildDate }}",
AmiDescription = "Build AMI",
AmiKmsKey = Key.FromLookup(this, "ComponentKey", new KeyLookupOptions { AliasName = "alias/distribution-encryption-key" }),
// Copy the AMI to different accounts
AmiTargetAccountIds = new [] { "123456789012", "098765432109" },
// Add launch permissions on the AMI
AmiLaunchPermission = new AmiLaunchPermission {
OrganizationArns = new [] { FormatArn(new ArnComponents { Region = "", Service = "organizations", Resource = "organization", ResourceName = "o-1234567abc" }) },
OrganizationalUnitArns = new [] { FormatArn(new ArnComponents {
Region = "",
Service = "organizations",
Resource = "ou",
ResourceName = "o-1234567abc/ou-a123-b4567890"
}) },
IsPublicUserGroup = true,
AccountIds = new [] { "234567890123" }
},
// Attach tags to the AMI
AmiTags = new Dictionary<string, string> {
{ "Environment", "production" },
{ "Version", "{{ imagebuilder:buildVersion }}" }
},
// Optional - publish the distributed AMI ID to an SSM parameter
SsmParameters = new [] { new SSMParameterConfigurations {
Parameter = StringParameter.FromStringParameterAttributes(this, "Parameter", new StringParameterAttributes {
ParameterName = "/imagebuilder/ami",
ForceDynamicReference = true
})
}, new SSMParameterConfigurations {
AmiAccount = "098765432109",
DataType = ParameterDataType.TEXT,
Parameter = StringParameter.FromStringParameterAttributes(this, "CrossAccountParameter", new StringParameterAttributes {
ParameterName = "imagebuilder-prod-ami",
ForceDynamicReference = true
})
} },
// Optional - create a new launch template version with the distributed AMI ID
LaunchTemplates = new [] { new LaunchTemplateConfiguration {
LaunchTemplate = LaunchTemplate.FromLaunchTemplateAttributes(this, "LaunchTemplate", new LaunchTemplateAttributes {
LaunchTemplateId = "lt-1234"
}),
SetDefaultVersion = true
}, new LaunchTemplateConfiguration {
AccountId = "123456789012",
LaunchTemplate = LaunchTemplate.FromLaunchTemplateAttributes(this, "CrossAccountLaunchTemplate", new LaunchTemplateAttributes {
LaunchTemplateId = "lt-5678"
}),
SetDefaultVersion = true
} },
// Optional - enable Fast Launch on an imported launch template
FastLaunchConfigurations = new [] { new FastLaunchConfiguration {
Enabled = true,
LaunchTemplate = LaunchTemplate.FromLaunchTemplateAttributes(this, "FastLaunchLT", new LaunchTemplateAttributes {
LaunchTemplateName = "fast-launch-lt"
}),
MaxParallelLaunches = 10,
TargetSnapshotCount = 2
} },
// Optional - license configurations to apply to the AMI
LicenseConfigurationArns = new [] { "arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-abcdefghijklmnopqrstuvwxyz" }
});
Properties
LaunchTemplateId
The identifier of the Launch Template.
public string? LaunchTemplateId { get; set; }
Property Value
Remarks
Exactly one of launchTemplateId and launchTemplateName may be set.
Default: None
LaunchTemplateName
The name of the Launch Template.
public string? LaunchTemplateName { get; set; }
Property Value
Remarks
Exactly one of launchTemplateId and launchTemplateName may be set.
Default: None
VersionNumber
The version number of this launch template to use.
public string? VersionNumber { get; set; }
Property Value
Remarks
Default: Version: "$Default"