CreateWorkloadIdentityTemplate
Creates a workload identity template under a workload identity provider.
The operation accepts two mutually exclusive modes, and the member you supply decides
which one you are in. TemplateDefinition puts the request in template
definition mode, and PathPattern puts it in direct authoring mode.
Use template definition mode when a service-owned definition already covers the workload you are onboarding. IAM then renders the pattern and the attestation policy for you, so there is less to get wrong. Use direct authoring mode when no definition covers your case, or when you need a pattern or an attestation policy that the available definitions do not offer.
-
Template definition mode – You name a service-owned definition through
TemplateDefinitionand supply only the values that definition leaves open. WorkloadIdentityTemplateDefinitionType carries which values a given definition leaves open and the name it gives each one. IAM rendersPathPatternandAttestationPolicyfrom the definition, so you author neither. In this mode,Tagsis the only other request parameter you can supply. -
Direct authoring mode – You must supply
Name,WorkloadIdentityProviderArnandPathPatternyourself, and you can supplyDescription,PathPrefix,AttestationPolicyandTags.
Because the two modes make different members mandatory, no member of this request is
unconditionally required, and every parameter below therefore reads Required:
No. The per-mode rules are what govern. TemplateDefinition is
required in template definition mode and forbidden in direct authoring mode.
Name, WorkloadIdentityProviderArn and PathPattern
are required in direct authoring mode and forbidden in template definition mode, where
IAM renders all three from the definition.
AttestationPolicy is optional on this operation. A policy supplied here
is equivalent to one supplied later by PutWorkloadIdentityTemplateAttestationPolicy, and a template created
without one admits nothing until a policy is set.
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
- AttestationPolicy
-
The attestation policy that decides which workloads can be attested through the template. A policy supplied here is equivalent to one supplied later by PutWorkloadIdentityTemplateAttestationPolicy.
Forbidden in template definition mode, where the service renders the policy from the definition.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 131072.
Pattern:
[\u0009\u000A\u000D\u0020-\u00FF]+Required: No
- Description
-
A description of the template. If you omit it, the template carries no description and responses omit the
Descriptionelement.Forbidden in template definition mode.
Type: String
Length Constraints: Minimum length of 0. Maximum length of 1000.
Pattern:
^[\u0009\u000A\u000D\u0020-\u007E\u00A1-\u00FF]*$Required: No
- Name
-
The name of the template. It is the leaf of the template's own resource ARN and it does not appear in any rendered identifier.
Required in direct authoring mode, and forbidden in template definition mode.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Pattern:
^[A-Za-z0-9_-]+$Required: No
- PathPattern
-
The pattern that workload identifiers are rendered from. For the pattern grammar, and for the checks the regular expression cannot express, see WorkloadIdentityTemplatePathPatternType.
Required in direct authoring mode, and forbidden in template definition mode, where the service renders it from the definition.
Type: String
Length Constraints: Minimum length of 3. Maximum length of 16384.
Pattern:
^(?=.*\{)(?:\{[A-Za-z0-9:/._-]+\}|(?!\.{1,2}(?:/|$))[A-Za-z0-9._-]+)(?:/(?:\{[A-Za-z0-9:/._-]+\}|(?!\.{1,2}(?:/|$))[A-Za-z0-9._-]+))*$Required: No
- PathPrefix
-
The namespace between the provider's naming root and the rendered pattern. Segments only, with no leading slash, no trailing slash and no empty segment.
Forbidden in template definition mode.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 64.
Pattern:
^(?!\.{1,2}(?:/|$))[A-Za-z0-9._-]+(?:/(?!\.{1,2}(?:/|$))[A-Za-z0-9._-]+)*$Required: No
- ResourceScope
-
The scope the template is created at. An
ORGANIZATION-scoped template belongs to your organization. If you do not include this parameter, it defaults toACCOUNT.An
ORGANIZATION-scoped template must reference an organization-scoped provider. AnACCOUNT-scoped template can reference an account-scoped provider in your account or an organization-scoped provider in your organization.Forbidden in template definition mode.
Type: String
Valid Values:
ACCOUNT | ORGANIZATIONRequired: No
- Tags.member.N
-
A list of tags that you want to attach to the new template. Each tag consists of a key name and an associated value. Tag keys are case sensitive, and two tag keys that differ only in case are rejected with
InvalidInputException. For more information about tagging, see Tagging IAM resources in the IAM User Guide.Tagsis accepted in both modes. A template definition never carries tags of its own.NoteIf any one of the tags is invalid or if you exceed the allowed maximum number of tags, then the entire request fails and the resource is not created.
Type: Array of Tag objects
Array Members: Maximum number of 50 items.
Required: No
- TemplateDefinition
-
The service-owned definition to render the template from, carrying only the values that definition leaves open. For the values a definition leaves open and the name of each, see WorkloadIdentityTemplateDefinitionType.
Supplying this parameter selects template definition mode. It is forbidden in direct authoring mode.
Type: WorkloadIdentityTemplateDefinitionType object
Required: No
- WorkloadIdentityProviderArn
-
The Amazon Resource Name (ARN) of the workload identity provider to create the template under.
Required in direct authoring mode, and forbidden in template definition mode, where the service renders it from the definition.
Type: String
Length Constraints: Minimum length of 20. Maximum length of 2048.
Required: No
Response Elements
The following elements are returned by the service.
- Arn
-
The template's own Amazon Resource Name (ARN).
Nameis its leaf. For more information about ARNs, see Amazon Resource Names (ARNs) in the AWS General Reference.For an
ORGANIZATION-scoped template, the account segment of the ARN is the organization ID, for examplearn:aws:iam::o-abc123def4:workload-identity-template/PaymentsFleet.Type: String
Length Constraints: Minimum length of 20. Maximum length of 2048.
- AttestationPolicy
-
The attestation policy set by this call. Echoed when a policy was set by this call, and omitted otherwise.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 131072.
Pattern:
[\u0009\u000A\u000D\u0020-\u00FF]+ - CreateDate
-
The date and time, in ISO 8601 date-time format, when the template was created.
Type: Timestamp
- Description
-
The description of the template. Omitted when none was supplied.
Type: String
Length Constraints: Minimum length of 0. Maximum length of 1000.
Pattern:
^[\u0009\u000A\u000D\u0020-\u007E\u00A1-\u00FF]*$ - Name
-
The name of the template. In template definition mode, the service renders it from the definition.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Pattern:
^[A-Za-z0-9_-]+$ - PathPattern
-
The pattern that workload identifiers are rendered from.
Type: String
Length Constraints: Minimum length of 3. Maximum length of 16384.
Pattern:
^(?=.*\{)(?:\{[A-Za-z0-9:/._-]+\}|(?!\.{1,2}(?:/|$))[A-Za-z0-9._-]+)(?:/(?:\{[A-Za-z0-9:/._-]+\}|(?!\.{1,2}(?:/|$))[A-Za-z0-9._-]+))*$ - PathPrefix
-
The namespace the pattern sits under. Omitted when none was supplied.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 64.
Pattern:
^(?!\.{1,2}(?:/|$))[A-Za-z0-9._-]+(?:/(?!\.{1,2}(?:/|$))[A-Za-z0-9._-]+)*$ - ResourceScope
-
The resolved scope, so you learn which scope applied even when you omitted the parameter.
Type: String
Valid Values:
ACCOUNT | ORGANIZATION - Tags.member.N
-
The tags attached to the template. Omitted when no tags were supplied. For more information about tagging, see Tagging IAM resources in the IAM User Guide.
Type: Array of Tag objects
Array Members: Maximum number of 50 items.
- TemplateId
-
The template's immutable identifier, which is distinct from its ARN. IAM prefixes it with
AWTAfor an account-scoped template andAWTOfor an organization-scoped template. A template that is deleted and recreated under the same name keeps the ARN but gets a new identifier.Type: String
Length Constraints: Minimum length of 16. Maximum length of 128.
Pattern:
[\w]+ - WorkloadIdentityProviderArn
-
The Amazon Resource Name (ARN) of the provider the template was created under. In template definition mode, the service renders it from the definition.
Type: String
Length Constraints: Minimum length of 20. Maximum length of 2048.
Errors
For information about the errors that are common to all actions, see Common Error Types.
- ConcurrentModification
-
The request was rejected because multiple requests to change this object were submitted simultaneously. Wait a few minutes and submit your request again.
HTTP Status Code: 409
- EntityAlreadyExists
-
The request was rejected because it attempted to create a resource that already exists.
HTTP Status Code: 409
- InvalidInput
-
The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
HTTP Status Code: 400
- LimitExceeded
-
The request was rejected because it attempted to create resources beyond the current AWS account limits. The error message describes the limit exceeded.
HTTP Status Code: 409
- MalformedPolicyDocument
-
The request was rejected because the policy document was malformed. The error message describes the specific error.
HTTP Status Code: 400
- NoSuchEntity
-
The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.
HTTP Status Code: 404
- ServiceFailure
-
The request processing has failed because of an unknown error, exception or failure.
HTTP Status Code: 500
Examples
Example – Create a template in direct authoring mode
The following example is formatted with line breaks for legibility.
Sample Request
https://iam.amazonaws.com/?Action=CreateWorkloadIdentityTemplate
&Name=PaymentsFleet
&WorkloadIdentityProviderArn=arn:aws:iam::111122223333:workload-identity-provider/PaymentsProd
&ResourceScope=ACCOUNT
&PathPrefix=payments
&PathPattern={aws:WorkloadAttestation/aws/eks/ClusterName}/prod/{aws:WorkloadAttestation/aws/eks/Namespace}
&Description=Payments%20fleet%20workloads%20attested%20through%20EKS
&AttestationPolicy={"Version":"2012-10-17","Statement":[{"Effect":"Allow",
"Principal":{"Service":["eks.amazonaws.com"]},
"Action":["sts:IssueWorkloadIdentityContext"],
"Condition":{"StringEquals":{"aws:WorkloadAttestation/aws/eks/ClusterName":"payments-prod"}}}]}
&Tags.member.1.Key=Team
&Tags.member.1.Value=Payments
&Version=2010-05-08
&AUTHPARAMS
Sample Response
<CreateWorkloadIdentityTemplateResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
<CreateWorkloadIdentityTemplateResult>
<Name>PaymentsFleet</Name>
<TemplateId>AWTAI3LGJ4EXAMPLE</TemplateId>
<Description>Payments fleet workloads attested through EKS</Description>
<ResourceScope>ACCOUNT</ResourceScope>
<Arn>arn:aws:iam::111122223333:workload-identity-template/PaymentsFleet</Arn>
<WorkloadIdentityProviderArn>arn:aws:iam::111122223333:workload-identity-provider/PaymentsProd</WorkloadIdentityProviderArn>
<PathPrefix>payments</PathPrefix>
<PathPattern>{aws:WorkloadAttestation/aws/eks/ClusterName}/prod/{aws:WorkloadAttestation/aws/eks/Namespace}</PathPattern>
<AttestationPolicy>{"Version":"2012-10-17","Statement":[{"Effect":"Allow",
"Principal":{"Service":["eks.amazonaws.com"]},"Action":["sts:IssueWorkloadIdentityContext"],
"Condition":{"StringEquals":{"aws:WorkloadAttestation/aws/eks/ClusterName":"payments-prod"}}}]}</AttestationPolicy>
<Tags>
<member>
<Key>Team</Key>
<Value>Payments</Value>
</member>
</Tags>
<CreateDate>2012-05-08T23:34:01.495Z</CreateDate>
</CreateWorkloadIdentityTemplateResult>
<ResponseMetadata>
<RequestId>4a93ceee-9966-11e1-b624-b1aEXAMPLE7c</RequestId>
</ResponseMetadata>
</CreateWorkloadIdentityTemplateResponse>
Example – Create a template in template definition mode
IAM renders Name, PathPattern and the attestation
policy from the definition, so you author none of them.
Sample Request
https://iam.amazonaws.com/?Action=CreateWorkloadIdentityTemplate
&TemplateDefinition.TemplateDefinitionArn=arn:aws:iam::aws:workload-identity-template-definition/eks.amazonaws.com/default:1
&TemplateDefinition.ReplacementValues.entry.1.key=ClusterName
&TemplateDefinition.ReplacementValues.entry.1.value.Values.member.1=payments-prod
&Tags.member.1.Key=Team
&Tags.member.1.Value=Payments
&Version=2010-05-08
&AUTHPARAMS
Sample Response
<CreateWorkloadIdentityTemplateResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
<CreateWorkloadIdentityTemplateResult>
<Name>EksDefaultEXAMPLE</Name>
<TemplateId>AWTAC2ICXG32EXAMPLEWK</TemplateId>
<ResourceScope>ACCOUNT</ResourceScope>
<Arn>arn:aws:iam::111122223333:workload-identity-template/EksDefaultEXAMPLE</Arn>
<WorkloadIdentityProviderArn>arn:aws:iam::111122223333:workload-identity-provider/PaymentsProd</WorkloadIdentityProviderArn>
<PathPattern>{aws:WorkloadAttestation/aws/eks/ClusterName}/{aws:WorkloadAttestation/aws/eks/Namespace}</PathPattern>
<Tags>
<member>
<Key>Team</Key>
<Value>Payments</Value>
</member>
</Tags>
<CreateDate>2012-05-08T23:34:01.495Z</CreateDate>
</CreateWorkloadIdentityTemplateResult>
<ResponseMetadata>
<RequestId>4a93ceee-9966-11e1-b624-b1aEXAMPLE7c</RequestId>
</ResponseMetadata>
</CreateWorkloadIdentityTemplateResponse>
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: