AWS Identity and Access Management (IAM)
Since Camel 3.1
Only producer is supported
The AWS2 IAM component supports create, run, start, stop and terminate AWS IAM instances.
Prerequisites
You must have a valid Amazon Web Services developer account, and be signed up to use Amazon IAM. More information is available at Amazon IAM.
URI Format
aws2-iam://label[?options]
You can append query options to the URI in the following format:
?options=value&option2=value&…
| The AWS2 IAM component works on the aws-global region, and it has aws-global as the default region |
Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The AWS Identity and Access Management (IAM) component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
The configuration that the endpoints of the component start from. Each endpoint uses a copy of it, in which its own URI options replace the values. | IAM2Configuration | ||
Autowired To use a custom software.amazon.awssdk.services.iam.IamClient. When this option is set or autowired, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used to build a client. The Camel endpoint does not close a client that is set or autowired. | IamClient | ||
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
The operation that the producer performs. The CamelAwsIAMOperation header replaces this option. If neither is set, the exchange fails. Enum values:
| IAM2Operations | ||
Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set. | false | boolean | |
Whether the body is the request object of the AWS SDK for the operation, such as a CreateUserRequest, which the producer sends as it is. The headers that give the input of the operation are then not used, and an empty body or a body of another type fails the exchange. | false | boolean | |
The AWS region of the IAM client, as a region ID such as aws-global, which is the value of Region.AWS_GLOBAL.id(). IAM is a global service: the default aws-global is for the standard AWS partition, and aws-cn-global and aws-us-gov-global are for the China and AWS GovCloud (US) partitions. Enum values:
| aws-global | String | |
The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true. | String | ||
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean | |
Used for enabling or disabling all consumer based health checks from this component. | true | boolean | |
Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true. | true | boolean | |
The host name of the proxy that the HTTP client of IAM connects through. The proxy is used only when the proxyPort option is set too. | String | ||
The port of the proxy that the HTTP client of IAM connects through. The proxy is used only when the proxyHost option is set too. | Integer | ||
The protocol that the HTTP client of IAM uses to connect to the proxy. It is used only when the proxyHost and proxyPort options are set. Enum values:
| HTTPS | Protocol | |
The access key ID of the AWS credentials, used together with the secretKey option. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true. | String | ||
The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change. | String | ||
The secret access key of the AWS credentials, used together with the accessKey option. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true. | String | ||
The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. | String | ||
Whether the HTTP client of IAM trusts every TLS certificate without checking it. It applies to any endpoint, not only to an overridden one, so use it only for testing, for example against a local emulator. | false | boolean | |
Whether to load the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options. | false | boolean | |
Whether to load the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials. | false | boolean | |
Whether to use temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true. | false | boolean |
Endpoint Options
The AWS Identity and Access Management (IAM) endpoint is configured using URI syntax:
aws2-iam:label
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
Autowired To use a custom software.amazon.awssdk.services.iam.IamClient. When this option is set or autowired, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used to build a client. The Camel endpoint does not close a client that is set or autowired. | IamClient | ||
The operation that the producer performs. The CamelAwsIAMOperation header replaces this option. If neither is set, the exchange fails. Enum values:
| IAM2Operations | ||
Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set. | false | boolean | |
Whether the body is the request object of the AWS SDK for the operation, such as a CreateUserRequest, which the producer sends as it is. The headers that give the input of the operation are then not used, and an empty body or a body of another type fails the exchange. | false | boolean | |
The AWS region of the IAM client, as a region ID such as aws-global, which is the value of Region.AWS_GLOBAL.id(). IAM is a global service: the default aws-global is for the standard AWS partition, and aws-cn-global and aws-us-gov-global are for the China and AWS GovCloud (US) partitions. Enum values:
| aws-global | String | |
The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true. | String | ||
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
The host name of the proxy that the HTTP client of IAM connects through. The proxy is used only when the proxyPort option is set too. | String | ||
The port of the proxy that the HTTP client of IAM connects through. The proxy is used only when the proxyHost option is set too. | Integer | ||
The protocol that the HTTP client of IAM uses to connect to the proxy. It is used only when the proxyHost and proxyPort options are set. Enum values:
| HTTPS | Protocol | |
The access key ID of the AWS credentials, used together with the secretKey option. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true. | String | ||
The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change. | String | ||
The secret access key of the AWS credentials, used together with the accessKey option. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true. | String | ||
The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. | String | ||
Whether the HTTP client of IAM trusts every TLS certificate without checking it. It applies to any endpoint, not only to an overridden one, so use it only for testing, for example against a local emulator. | false | boolean | |
Whether to load the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options. | false | boolean | |
Whether to load the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials. | false | boolean | |
Whether to use temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true. | false | boolean |
Message Headers
The AWS Identity and Access Management (IAM) component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
CamelAwsIAMOperation (producer) Constant: | The operation that the producer performs. It replaces the operation option. | String | |
CamelAwsIAMUsername (producer) Constant: | The name of the IAM user. createUser, deleteUser, getUser, addUserToGroup, removeUserFromGroup, attachUserPolicy and detachUserPolicy require it. listAccessKeys, createAccessKey, deleteAccessKey and updateAccessKey use it to select the user of the access key; when not set, IAM takes the user of the access key that signs the request. | String | |
CamelAwsIAMAccessKeyID (producer) Constant: | The ID of the access key that deleteAccessKey deletes or updateAccessKey updates. Both operations require it. | String | |
CamelAwsIAMAccessKeyStatus (producer) Constant: | The status that updateAccessKey sets on the access key: Active or Inactive, in any case. updateAccessKey requires it, and another value fails the exchange. | String | |
CamelAwsIAMGroupName (producer) Constant: | The name of the IAM group. createGroup, deleteGroup, addUserToGroup, removeUserFromGroup, attachGroupPolicy and detachGroupPolicy require it. | String | |
CamelAwsIAMGroupPath (producer) Constant: | The path of the group that createGroup creates, such as /division_abc/. When not set, IAM uses the path /. | String | |
| Constant: | The marker of the CamelAwsIAMNextMarker header of the previous response, to get the next page of results of a list operation: listAccessKeys, listUsers, listGroups, listRoles, listPolicies or listInstanceProfiles. | String | |
CamelAwsIAMMaxItems (producer) Constant: | The maximum number of items in one page of results of a list operation: listAccessKeys, listUsers, listGroups, listRoles, listPolicies or listInstanceProfiles. IAM accepts 1 to 1000, and returns at most 100 items when not set. | Integer | |
CamelAwsIAMIsTruncated (producer) Constant: | Whether a list operation has more results than it returned. When true, the CamelAwsIAMNextMarker header gives the marker of the next page. | Boolean | |
CamelAwsIAMNextMarker (producer) Constant: | The marker that a list operation sets when it has more results. Send it in the CamelAwsIAMMarker header to get the next page. | String | |
| Constant: | The ARN of the user that createUser created or getUser returned. | String | |
| Constant: | The unique ID that IAM gave to the user that createUser created or getUser returned. | String | |
CamelAwsIAMGroupArn (producer) Constant: | The ARN of the group that createGroup created. | String | |
| Constant: | The unique ID that IAM gave to the group that createGroup created. | String | |
CamelAwsIAMRoleName (producer) Constant: | The name of the IAM role. createRole, deleteRole, getRole, attachRolePolicy, detachRolePolicy, addRoleToInstanceProfile and removeRoleFromInstanceProfile require it. | String | |
CamelAwsIAMRolePath (producer) Constant: | The path of the role that createRole creates. When not set, IAM uses the path /. | String | |
CamelAwsIAMAssumeRolePolicyDocument (producer) Constant: | The trust policy of the role that createRole creates, as a JSON policy document that says which principals can assume the role. createRole requires it. | String | |
| Constant: | The ARN of the role that createRole created or getRole returned. | String | |
| Constant: | The unique ID that IAM gave to the role that createRole created or getRole returned. | String | |
CamelAwsIAMRoleDescription (producer) Constant: | The description of the role that createRole creates. | String | |
CamelAwsIAMPolicyName (producer) Constant: | The name of the managed policy that createPolicy creates. createPolicy requires it. | String | |
CamelAwsIAMPolicyPath (producer) Constant: | The path of the managed policy that createPolicy creates. When not set, IAM uses the path /. | String | |
CamelAwsIAMPolicyDocument (producer) Constant: | The JSON policy document of the managed policy that createPolicy creates, with the permissions of the policy. createPolicy requires it. | String | |
CamelAwsIAMPolicyArn (producer) Constant: | The ARN of the managed policy. deletePolicy, getPolicy and the operations that attach a policy to or detach it from a user, group or role require it. createPolicy and getPolicy set it to the ARN of the created or returned policy. | String | |
CamelAwsIAMPolicyId (producer) Constant: | The unique ID that IAM gave to the managed policy that createPolicy created or getPolicy returned. | String | |
CamelAwsIAMPolicyDescription (producer) Constant: | The description of the managed policy that createPolicy creates. | String | |
CamelAwsIAMInstanceProfileName (producer) Constant: | The name of the instance profile. createInstanceProfile, deleteInstanceProfile, getInstanceProfile, addRoleToInstanceProfile and removeRoleFromInstanceProfile require it. | String | |
CamelAwsIAMInstanceProfilePath (producer) Constant: | The path of the instance profile that createInstanceProfile creates. When not set, IAM uses the path /. | String | |
CamelAwsIAMInstanceProfileArn (producer) Constant: | The ARN of the instance profile that createInstanceProfile created or getInstanceProfile returned. | String | |
CamelAwsIAMInstanceProfileId (producer) Constant: | The unique ID that IAM gave to the instance profile that createInstanceProfile created or getInstanceProfile returned. | String |
Message Body
The message body at each side of the AWS Identity and Access Management (IAM) component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.
| Side | Body | Description |
|---|---|---|
Producer input |
| Not used: the names, the ARNs and the policy documents come from headers, such as CamelAwsIAMUsername. With pojoRequest=true the request of the AWS SDK for the operation, such as a CreateUserRequest: another body fails.
|
Producer output |
| The response of the AWS SDK for the operation, such as the CreateUserResponse of createUser; the create and get operations put the ARN and the id in headers too. |
The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.
Required IAM component options
You have to provide the amazonKmsClient in the Registry or your accessKey and secretKey to access the Amazon IAM service.
Usage
Static credentials, Default Credential Provider and Profile Credentials Provider
You have the possibility of avoiding the usage of explicit static credentials by specifying the useDefaultCredentialsProvider option and set it to true.
The order of evaluation for Default Credentials Provider is the following:
-
Java system properties -
aws.accessKeyIdandaws.secretKey. -
Environment variables -
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY. -
Web Identity Token from AWS STS.
-
The shared credentials and config files.
-
Amazon ECS container credentials - loaded from the Amazon ECS if the environment variable
AWS_CONTAINER_CREDENTIALS_RELATIVE_URIis set. -
Amazon EC2 Instance profile credentials.
You have also the possibility of using Profile Credentials Provider, by specifying the useProfileCredentialsProvider option to true and profileCredentialsName to the profile name.
Only one of static, default and profile credentials could be used at the same time.
For more information about this you can look at AWS credentials documentation
IAM Producer operations
Camel-AWS2 IAM component provides the following operation on the producer side:
-
listAccessKeys
-
createUser
-
deleteUser
-
listUsers
-
getUser
-
createAccessKey
-
deleteAccessKey
-
updateAccessKey
-
createGroup
-
deleteGroup
-
listGroups
-
addUserToGroup
-
removeUserFromGroup
-
createRole
-
deleteRole
-
getRole
-
listRoles
-
createPolicy
-
deletePolicy
-
getPolicy
-
listPolicies
-
attachUserPolicy
-
detachUserPolicy
-
attachGroupPolicy
-
detachGroupPolicy
-
attachRolePolicy
-
detachRolePolicy
-
createInstanceProfile
-
deleteInstanceProfile
-
getInstanceProfile
-
listInstanceProfiles
-
addRoleToInstanceProfile
-
removeRoleFromInstanceProfile
Examples
Producer Examples
-
createUser: this operation will create a user in IAM
-
Java
-
XML
-
YAML
from("direct:createUser")
.setHeader("CamelAwsIAMUsername", constant("camel"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=createUser"); <route>
<from uri="direct:createUser"/>
<setHeader name="CamelAwsIAMUsername">
<constant>camel</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=createUser"/>
</route> - route:
from:
uri: direct:createUser
steps:
- setHeader:
name: CamelAwsIAMUsername
constant: camel
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: createUser -
deleteUser: this operation will delete a user in IAM
-
Java
-
XML
-
YAML
from("direct:deleteUser")
.setHeader("CamelAwsIAMUsername", constant("camel"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=deleteUser"); <route>
<from uri="direct:deleteUser"/>
<setHeader name="CamelAwsIAMUsername">
<constant>camel</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=deleteUser"/>
</route> - route:
from:
uri: direct:deleteUser
steps:
- setHeader:
name: CamelAwsIAMUsername
constant: camel
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: deleteUser -
listUsers: this operation will list the users in IAM
-
Java
-
XML
-
YAML
from("direct:listUsers")
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=listUsers"); <route>
<from uri="direct:listUsers"/>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=listUsers"/>
</route> - route:
from:
uri: direct:listUsers
steps:
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: listUsers -
createGroup: this operation will add a group in IAM
-
Java
-
XML
-
YAML
from("direct:createGroup")
.setHeader("CamelAwsIAMGroupName", constant("camel"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=createGroup"); <route>
<from uri="direct:createGroup"/>
<setHeader name="CamelAwsIAMGroupName">
<constant>camel</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=createGroup"/>
</route> - route:
from:
uri: direct:createGroup
steps:
- setHeader:
name: CamelAwsIAMGroupName
constant: camel
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: createGroup -
deleteGroup: this operation will delete a group in IAM
-
Java
-
XML
-
YAML
from("direct:deleteGroup")
.setHeader("CamelAwsIAMGroupName", constant("camel"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=deleteGroup"); <route>
<from uri="direct:deleteGroup"/>
<setHeader name="CamelAwsIAMGroupName">
<constant>camel</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=deleteGroup"/>
</route> - route:
from:
uri: direct:deleteGroup
steps:
- setHeader:
name: CamelAwsIAMGroupName
constant: camel
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: deleteGroup -
listGroups: this operation will list the groups in IAM
-
Java
-
XML
-
YAML
from("direct:listGroups")
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=listGroups"); <route>
<from uri="direct:listGroups"/>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=listGroups"/>
</route> - route:
from:
uri: direct:listGroups
steps:
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: listGroups Role Operations
-
createRole: this operation will create a role in IAM
-
Java
-
XML
-
YAML
from("direct:createRole")
.setHeader("CamelAwsIAMRoleName", constant("myRole"))
.setHeader("CamelAwsIAMAssumeRolePolicyDocument", constant("{...}"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=createRole"); <route>
<from uri="direct:createRole"/>
<setHeader name="CamelAwsIAMRoleName">
<constant>myRole</constant>
</setHeader>
<setHeader name="CamelAwsIAMAssumeRolePolicyDocument">
<constant>{...}</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=createRole"/>
</route> - route:
from:
uri: direct:createRole
steps:
- setHeader:
name: CamelAwsIAMRoleName
constant: myRole
- setHeader:
name: CamelAwsIAMAssumeRolePolicyDocument
constant: "{...}"
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: createRole -
deleteRole: this operation will delete a role in IAM
-
Java
-
XML
-
YAML
from("direct:deleteRole")
.setHeader("CamelAwsIAMRoleName", constant("myRole"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=deleteRole"); <route>
<from uri="direct:deleteRole"/>
<setHeader name="CamelAwsIAMRoleName">
<constant>myRole</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=deleteRole"/>
</route> - route:
from:
uri: direct:deleteRole
steps:
- setHeader:
name: CamelAwsIAMRoleName
constant: myRole
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: deleteRole -
getRole: this operation will get a role in IAM
-
Java
-
XML
-
YAML
from("direct:getRole")
.setHeader("CamelAwsIAMRoleName", constant("myRole"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=getRole"); <route>
<from uri="direct:getRole"/>
<setHeader name="CamelAwsIAMRoleName">
<constant>myRole</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=getRole"/>
</route> - route:
from:
uri: direct:getRole
steps:
- setHeader:
name: CamelAwsIAMRoleName
constant: myRole
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: getRole -
listRoles: this operation will list the roles in IAM
-
Java
-
XML
-
YAML
from("direct:listRoles")
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=listRoles"); <route>
<from uri="direct:listRoles"/>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=listRoles"/>
</route> - route:
from:
uri: direct:listRoles
steps:
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: listRoles Policy Operations
-
createPolicy: this operation will create a policy in IAM
-
Java
-
XML
-
YAML
from("direct:createPolicy")
.setHeader("CamelAwsIAMPolicyName", constant("myPolicy"))
.setHeader("CamelAwsIAMPolicyDocument", constant("{...}"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=createPolicy"); <route>
<from uri="direct:createPolicy"/>
<setHeader name="CamelAwsIAMPolicyName">
<constant>myPolicy</constant>
</setHeader>
<setHeader name="CamelAwsIAMPolicyDocument">
<constant>{...}</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=createPolicy"/>
</route> - route:
from:
uri: direct:createPolicy
steps:
- setHeader:
name: CamelAwsIAMPolicyName
constant: myPolicy
- setHeader:
name: CamelAwsIAMPolicyDocument
constant: "{...}"
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: createPolicy -
deletePolicy: this operation will delete a policy in IAM
-
Java
-
XML
-
YAML
from("direct:deletePolicy")
.setHeader("CamelAwsIAMPolicyArn", constant("arn:aws:iam::123456789012:policy/myPolicy"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=deletePolicy"); <route>
<from uri="direct:deletePolicy"/>
<setHeader name="CamelAwsIAMPolicyArn">
<constant>arn:aws:iam::123456789012:policy/myPolicy</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=deletePolicy"/>
</route> - route:
from:
uri: direct:deletePolicy
steps:
- setHeader:
name: CamelAwsIAMPolicyArn
constant: "arn:aws:iam::123456789012:policy/myPolicy"
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: deletePolicy -
getPolicy: this operation will get a policy in IAM
-
Java
-
XML
-
YAML
from("direct:getPolicy")
.setHeader("CamelAwsIAMPolicyArn", constant("arn:aws:iam::123456789012:policy/myPolicy"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=getPolicy"); <route>
<from uri="direct:getPolicy"/>
<setHeader name="CamelAwsIAMPolicyArn">
<constant>arn:aws:iam::123456789012:policy/myPolicy</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=getPolicy"/>
</route> - route:
from:
uri: direct:getPolicy
steps:
- setHeader:
name: CamelAwsIAMPolicyArn
constant: "arn:aws:iam::123456789012:policy/myPolicy"
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: getPolicy -
listPolicies: this operation will list the policies in IAM
-
Java
-
XML
-
YAML
from("direct:listPolicies")
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=listPolicies"); <route>
<from uri="direct:listPolicies"/>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=listPolicies"/>
</route> - route:
from:
uri: direct:listPolicies
steps:
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: listPolicies Policy Attachment Operations
-
attachUserPolicy: this operation will attach a policy to a user
-
Java
-
XML
-
YAML
from("direct:attachUserPolicy")
.setHeader("CamelAwsIAMUsername", constant("camel"))
.setHeader("CamelAwsIAMPolicyArn", constant("arn:aws:iam::123456789012:policy/myPolicy"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=attachUserPolicy"); <route>
<from uri="direct:attachUserPolicy"/>
<setHeader name="CamelAwsIAMUsername">
<constant>camel</constant>
</setHeader>
<setHeader name="CamelAwsIAMPolicyArn">
<constant>arn:aws:iam::123456789012:policy/myPolicy</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=attachUserPolicy"/>
</route> - route:
from:
uri: direct:attachUserPolicy
steps:
- setHeader:
name: CamelAwsIAMUsername
constant: camel
- setHeader:
name: CamelAwsIAMPolicyArn
constant: "arn:aws:iam::123456789012:policy/myPolicy"
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: attachUserPolicy -
detachUserPolicy: this operation will detach a policy from a user
-
Java
-
XML
-
YAML
from("direct:detachUserPolicy")
.setHeader("CamelAwsIAMUsername", constant("camel"))
.setHeader("CamelAwsIAMPolicyArn", constant("arn:aws:iam::123456789012:policy/myPolicy"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=detachUserPolicy"); <route>
<from uri="direct:detachUserPolicy"/>
<setHeader name="CamelAwsIAMUsername">
<constant>camel</constant>
</setHeader>
<setHeader name="CamelAwsIAMPolicyArn">
<constant>arn:aws:iam::123456789012:policy/myPolicy</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=detachUserPolicy"/>
</route> - route:
from:
uri: direct:detachUserPolicy
steps:
- setHeader:
name: CamelAwsIAMUsername
constant: camel
- setHeader:
name: CamelAwsIAMPolicyArn
constant: "arn:aws:iam::123456789012:policy/myPolicy"
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: detachUserPolicy -
attachGroupPolicy: this operation will attach a policy to a group
-
Java
-
XML
-
YAML
from("direct:attachGroupPolicy")
.setHeader("CamelAwsIAMGroupName", constant("myGroup"))
.setHeader("CamelAwsIAMPolicyArn", constant("arn:aws:iam::123456789012:policy/myPolicy"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=attachGroupPolicy"); <route>
<from uri="direct:attachGroupPolicy"/>
<setHeader name="CamelAwsIAMGroupName">
<constant>myGroup</constant>
</setHeader>
<setHeader name="CamelAwsIAMPolicyArn">
<constant>arn:aws:iam::123456789012:policy/myPolicy</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=attachGroupPolicy"/>
</route> - route:
from:
uri: direct:attachGroupPolicy
steps:
- setHeader:
name: CamelAwsIAMGroupName
constant: myGroup
- setHeader:
name: CamelAwsIAMPolicyArn
constant: "arn:aws:iam::123456789012:policy/myPolicy"
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: attachGroupPolicy -
detachGroupPolicy: this operation will detach a policy from a group
-
Java
-
XML
-
YAML
from("direct:detachGroupPolicy")
.setHeader("CamelAwsIAMGroupName", constant("myGroup"))
.setHeader("CamelAwsIAMPolicyArn", constant("arn:aws:iam::123456789012:policy/myPolicy"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=detachGroupPolicy"); <route>
<from uri="direct:detachGroupPolicy"/>
<setHeader name="CamelAwsIAMGroupName">
<constant>myGroup</constant>
</setHeader>
<setHeader name="CamelAwsIAMPolicyArn">
<constant>arn:aws:iam::123456789012:policy/myPolicy</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=detachGroupPolicy"/>
</route> - route:
from:
uri: direct:detachGroupPolicy
steps:
- setHeader:
name: CamelAwsIAMGroupName
constant: myGroup
- setHeader:
name: CamelAwsIAMPolicyArn
constant: "arn:aws:iam::123456789012:policy/myPolicy"
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: detachGroupPolicy -
attachRolePolicy: this operation will attach a policy to a role
-
Java
-
XML
-
YAML
from("direct:attachRolePolicy")
.setHeader("CamelAwsIAMRoleName", constant("myRole"))
.setHeader("CamelAwsIAMPolicyArn", constant("arn:aws:iam::123456789012:policy/myPolicy"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=attachRolePolicy"); <route>
<from uri="direct:attachRolePolicy"/>
<setHeader name="CamelAwsIAMRoleName">
<constant>myRole</constant>
</setHeader>
<setHeader name="CamelAwsIAMPolicyArn">
<constant>arn:aws:iam::123456789012:policy/myPolicy</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=attachRolePolicy"/>
</route> - route:
from:
uri: direct:attachRolePolicy
steps:
- setHeader:
name: CamelAwsIAMRoleName
constant: myRole
- setHeader:
name: CamelAwsIAMPolicyArn
constant: "arn:aws:iam::123456789012:policy/myPolicy"
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: attachRolePolicy -
detachRolePolicy: this operation will detach a policy from a role
-
Java
-
XML
-
YAML
from("direct:detachRolePolicy")
.setHeader("CamelAwsIAMRoleName", constant("myRole"))
.setHeader("CamelAwsIAMPolicyArn", constant("arn:aws:iam::123456789012:policy/myPolicy"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=detachRolePolicy"); <route>
<from uri="direct:detachRolePolicy"/>
<setHeader name="CamelAwsIAMRoleName">
<constant>myRole</constant>
</setHeader>
<setHeader name="CamelAwsIAMPolicyArn">
<constant>arn:aws:iam::123456789012:policy/myPolicy</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=detachRolePolicy"/>
</route> - route:
from:
uri: direct:detachRolePolicy
steps:
- setHeader:
name: CamelAwsIAMRoleName
constant: myRole
- setHeader:
name: CamelAwsIAMPolicyArn
constant: "arn:aws:iam::123456789012:policy/myPolicy"
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: detachRolePolicy Instance Profile Operations
-
createInstanceProfile: this operation will create an instance profile in IAM
-
Java
-
XML
-
YAML
from("direct:createInstanceProfile")
.setHeader("CamelAwsIAMInstanceProfileName", constant("myInstanceProfile"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=createInstanceProfile"); <route>
<from uri="direct:createInstanceProfile"/>
<setHeader name="CamelAwsIAMInstanceProfileName">
<constant>myInstanceProfile</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=createInstanceProfile"/>
</route> - route:
from:
uri: direct:createInstanceProfile
steps:
- setHeader:
name: CamelAwsIAMInstanceProfileName
constant: myInstanceProfile
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: createInstanceProfile -
deleteInstanceProfile: this operation will delete an instance profile in IAM
-
Java
-
XML
-
YAML
from("direct:deleteInstanceProfile")
.setHeader("CamelAwsIAMInstanceProfileName", constant("myInstanceProfile"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=deleteInstanceProfile"); <route>
<from uri="direct:deleteInstanceProfile"/>
<setHeader name="CamelAwsIAMInstanceProfileName">
<constant>myInstanceProfile</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=deleteInstanceProfile"/>
</route> - route:
from:
uri: direct:deleteInstanceProfile
steps:
- setHeader:
name: CamelAwsIAMInstanceProfileName
constant: myInstanceProfile
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: deleteInstanceProfile -
getInstanceProfile: this operation will get an instance profile in IAM
-
Java
-
XML
-
YAML
from("direct:getInstanceProfile")
.setHeader("CamelAwsIAMInstanceProfileName", constant("myInstanceProfile"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=getInstanceProfile"); <route>
<from uri="direct:getInstanceProfile"/>
<setHeader name="CamelAwsIAMInstanceProfileName">
<constant>myInstanceProfile</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=getInstanceProfile"/>
</route> - route:
from:
uri: direct:getInstanceProfile
steps:
- setHeader:
name: CamelAwsIAMInstanceProfileName
constant: myInstanceProfile
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: getInstanceProfile -
listInstanceProfiles: this operation will list the instance profiles in IAM
-
Java
-
XML
-
YAML
from("direct:listInstanceProfiles")
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=listInstanceProfiles"); <route>
<from uri="direct:listInstanceProfiles"/>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=listInstanceProfiles"/>
</route> - route:
from:
uri: direct:listInstanceProfiles
steps:
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: listInstanceProfiles -
addRoleToInstanceProfile: this operation will add a role to an instance profile
-
Java
-
XML
-
YAML
from("direct:addRoleToInstanceProfile")
.setHeader("CamelAwsIAMInstanceProfileName", constant("myInstanceProfile"))
.setHeader("CamelAwsIAMRoleName", constant("myRole"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=addRoleToInstanceProfile"); <route>
<from uri="direct:addRoleToInstanceProfile"/>
<setHeader name="CamelAwsIAMInstanceProfileName">
<constant>myInstanceProfile</constant>
</setHeader>
<setHeader name="CamelAwsIAMRoleName">
<constant>myRole</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=addRoleToInstanceProfile"/>
</route> - route:
from:
uri: direct:addRoleToInstanceProfile
steps:
- setHeader:
name: CamelAwsIAMInstanceProfileName
constant: myInstanceProfile
- setHeader:
name: CamelAwsIAMRoleName
constant: myRole
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: addRoleToInstanceProfile -
removeRoleFromInstanceProfile: this operation will remove a role from an instance profile
-
Java
-
XML
-
YAML
from("direct:removeRoleFromInstanceProfile")
.setHeader("CamelAwsIAMInstanceProfileName", constant("myInstanceProfile"))
.setHeader("CamelAwsIAMRoleName", constant("myRole"))
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=removeRoleFromInstanceProfile"); <route>
<from uri="direct:removeRoleFromInstanceProfile"/>
<setHeader name="CamelAwsIAMInstanceProfileName">
<constant>myInstanceProfile</constant>
</setHeader>
<setHeader name="CamelAwsIAMRoleName">
<constant>myRole</constant>
</setHeader>
<to uri="aws2-iam://test?iamClient=#amazonIAMClient&operation=removeRoleFromInstanceProfile"/>
</route> - route:
from:
uri: direct:removeRoleFromInstanceProfile
steps:
- setHeader:
name: CamelAwsIAMInstanceProfileName
constant: myInstanceProfile
- setHeader:
name: CamelAwsIAMRoleName
constant: myRole
- to:
uri: aws2-iam://test
parameters:
iamClient: "#amazonIAMClient"
operation: removeRoleFromInstanceProfile Using a POJO as body
Sometimes building an AWS Request can be complex because of multiple options. We introduce the possibility to use a POJO as a body. In AWS IAM, there are multiple operations you can submit, as an example for Create User request, you can do something like:
from("direct:createUser")
.setBody(CreateUserRequest.builder().userName("camel").build())
.to("aws2-iam://test?iamClient=#amazonIAMClient&operation=createUser&pojoRequest=true") In this way, you’ll pass the request directly without the need of passing headers and options specifically related to this operation.
Dependencies
Maven users will need to add the following dependency to their pom.xml.
pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-aws2-iam</artifactId>
<version>${camel-version}</version>
</dependency> where ${camel-version} must be replaced by the actual version of Camel.