All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.cloudshiftdev.awscdk.services.iam.InstanceProfile.kt Maven / Gradle / Ivy

The newest version!
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")

package io.cloudshiftdev.awscdk.services.iam

import io.cloudshiftdev.awscdk.Resource
import io.cloudshiftdev.awscdk.common.CdkDslMarker
import kotlin.String
import kotlin.Unit
import kotlin.jvm.JvmName
import io.cloudshiftdev.constructs.Construct as CloudshiftdevConstructsConstruct
import software.constructs.Construct as SoftwareConstructsConstruct

/**
 * IAM Instance Profile.
 *
 * Example:
 *
 * ```
 * Role role = Role.Builder.create(this, "Role")
 * .assumedBy(new ServicePrincipal("ec2.amazonaws.com"))
 * .build();
 * IInstanceProfile instanceProfile = InstanceProfile.fromInstanceProfileAttributes(this,
 * "ImportedInstanceProfile", InstanceProfileAttributes.builder()
 * .instanceProfileArn("arn:aws:iam::account-id:instance-profile/MyInstanceProfile")
 * .role(role)
 * .build());
 * ```
 */
public open class InstanceProfile(
  cdkObject: software.amazon.awscdk.services.iam.InstanceProfile,
) : Resource(cdkObject),
    IInstanceProfile {
  public constructor(scope: CloudshiftdevConstructsConstruct, id: String) :
      this(software.amazon.awscdk.services.iam.InstanceProfile(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
      id)
  )

  public constructor(
    scope: CloudshiftdevConstructsConstruct,
    id: String,
    props: InstanceProfileProps,
  ) :
      this(software.amazon.awscdk.services.iam.InstanceProfile(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
      id, props.let(InstanceProfileProps.Companion::unwrap))
  )

  public constructor(
    scope: CloudshiftdevConstructsConstruct,
    id: String,
    props: InstanceProfileProps.Builder.() -> Unit,
  ) : this(scope, id, InstanceProfileProps(props)
  )

  /**
   * Returns the ARN of this InstanceProfile.
   */
  public override fun instanceProfileArn(): String = unwrap(this).getInstanceProfileArn()

  /**
   * Returns the name of this InstanceProfile.
   */
  public override fun instanceProfileName(): String = unwrap(this).getInstanceProfileName()

  /**
   * Returns the role associated with this InstanceProfile.
   */
  public override fun role(): IRole? = unwrap(this).getRole()?.let(IRole::wrap)

  /**
   * A fluent builder for [io.cloudshiftdev.awscdk.services.iam.InstanceProfile].
   */
  @CdkDslMarker
  public interface Builder {
    /**
     * The name of the InstanceProfile to create.
     *
     * Default: - generated by CloudFormation
     *
     * @param instanceProfileName The name of the InstanceProfile to create. 
     */
    public fun instanceProfileName(instanceProfileName: String)

    /**
     * The path to the InstanceProfile.
     *
     * Default: /
     *
     * @param path The path to the InstanceProfile. 
     */
    public fun path(path: String)

    /**
     * An IAM role to associate with the instance profile that is used by EC2 instances.
     *
     * The role must be assumable by the service principal `ec2.amazonaws.com`:
     *
     * Default: - a role will be automatically created, it can be accessed via the `role` property
     *
     * Example:
     *
     * ```
     * Role role = Role.Builder.create(this, "MyRole")
     * .assumedBy(new ServicePrincipal("ec2.amazonaws.com"))
     * .build();
     * ```
     *
     * @param role An IAM role to associate with the instance profile that is used by EC2 instances.
     * 
     */
    public fun role(role: IRole)
  }

  private class BuilderImpl(
    scope: SoftwareConstructsConstruct,
    id: String,
  ) : Builder {
    private val cdkBuilder: software.amazon.awscdk.services.iam.InstanceProfile.Builder =
        software.amazon.awscdk.services.iam.InstanceProfile.Builder.create(scope, id)

    /**
     * The name of the InstanceProfile to create.
     *
     * Default: - generated by CloudFormation
     *
     * @param instanceProfileName The name of the InstanceProfile to create. 
     */
    override fun instanceProfileName(instanceProfileName: String) {
      cdkBuilder.instanceProfileName(instanceProfileName)
    }

    /**
     * The path to the InstanceProfile.
     *
     * Default: /
     *
     * @param path The path to the InstanceProfile. 
     */
    override fun path(path: String) {
      cdkBuilder.path(path)
    }

    /**
     * An IAM role to associate with the instance profile that is used by EC2 instances.
     *
     * The role must be assumable by the service principal `ec2.amazonaws.com`:
     *
     * Default: - a role will be automatically created, it can be accessed via the `role` property
     *
     * Example:
     *
     * ```
     * Role role = Role.Builder.create(this, "MyRole")
     * .assumedBy(new ServicePrincipal("ec2.amazonaws.com"))
     * .build();
     * ```
     *
     * @param role An IAM role to associate with the instance profile that is used by EC2 instances.
     * 
     */
    override fun role(role: IRole) {
      cdkBuilder.role(role.let(IRole.Companion::unwrap))
    }

    public fun build(): software.amazon.awscdk.services.iam.InstanceProfile = cdkBuilder.build()
  }

  public companion object {
    public fun fromInstanceProfileArn(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      instanceProfileArn: String,
    ): IInstanceProfile =
        software.amazon.awscdk.services.iam.InstanceProfile.fromInstanceProfileArn(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        id, instanceProfileArn).let(IInstanceProfile::wrap)

    public fun fromInstanceProfileAttributes(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      attrs: InstanceProfileAttributes,
    ): IInstanceProfile =
        software.amazon.awscdk.services.iam.InstanceProfile.fromInstanceProfileAttributes(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        id, attrs.let(InstanceProfileAttributes.Companion::unwrap)).let(IInstanceProfile::wrap)

    @kotlin.Suppress("INAPPLICABLE_JVM_NAME")
    @JvmName("461d32d27355084613f43815133d12090dc7e621f74293219d07f03997428f89")
    public fun fromInstanceProfileAttributes(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      attrs: InstanceProfileAttributes.Builder.() -> Unit,
    ): IInstanceProfile = fromInstanceProfileAttributes(scope, id, InstanceProfileAttributes(attrs))

    public fun fromInstanceProfileName(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      instanceProfileName: String,
    ): IInstanceProfile =
        software.amazon.awscdk.services.iam.InstanceProfile.fromInstanceProfileName(scope.let(CloudshiftdevConstructsConstruct.Companion::unwrap),
        id, instanceProfileName).let(IInstanceProfile::wrap)

    public operator fun invoke(
      scope: CloudshiftdevConstructsConstruct,
      id: String,
      block: Builder.() -> Unit = {},
    ): InstanceProfile {
      val builderImpl = BuilderImpl(CloudshiftdevConstructsConstruct.unwrap(scope), id)
      return InstanceProfile(builderImpl.apply(block).build())
    }

    internal fun wrap(cdkObject: software.amazon.awscdk.services.iam.InstanceProfile):
        InstanceProfile = InstanceProfile(cdkObject)

    internal fun unwrap(wrapped: InstanceProfile):
        software.amazon.awscdk.services.iam.InstanceProfile = wrapped.cdkObject as
        software.amazon.awscdk.services.iam.InstanceProfile
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy