AWS Cloud9 examples using Tools for PowerShell - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

AWS Cloud9 examples using Tools for PowerShell

The following code examples show you how to perform actions and implement common scenarios by using the AWS Tools for PowerShell with AWS Cloud9.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use Get-C9EnvironmentData.

Tools for PowerShell

Example 1: This example gets information about the specified AWS Cloud9 development environments.

Get-C9EnvironmentData -EnvironmentId 685f892f431b45c2b28cb69eadcdb0EX,1980b80e5f584920801c09086667f0EX

Output:

Arn : arn:aws:cloud9:us-east-1:123456789012:environment:685f892f431b45c2b28cb69eadcdb0EX Description : Created from CodeStar. Id : 685f892f431b45c2b28cb69eadcdb0EX Lifecycle : Amazon.Cloud9.Model.EnvironmentLifecycle Name : my-demo-ec2-env OwnerArn : arn:aws:iam::123456789012:user/MyDemoUser Type : ec2 Arn : arn:aws:cloud9:us-east-1:123456789012:environment:1980b80e5f584920801c09086667f0EX Description : Id : 1980b80e5f584920801c09086667f0EX Lifecycle : Amazon.Cloud9.Model.EnvironmentLifecycle Name : my-demo-ssh-env OwnerArn : arn:aws:iam::123456789012:user/MyDemoUser Type : ssh

Example 2: This example gets information about the lifecycle status of the specified AWS Cloud9 development environment.

(Get-C9EnvironmentData -EnvironmentId 685f892f431b45c2b28cb69eadcdb0EX).Lifecycle

Output:

FailureResource Reason Status --------------- ------ ------ CREATED

The following code example shows how to use Get-C9EnvironmentList.

Tools for PowerShell

Example 1: This example gets a list of available AWS Cloud9 development environment identifiers.

Get-C9EnvironmentList

Output:

685f892f431b45c2b28cb69eadcdb0EX 1980b80e5f584920801c09086667f0EX
  • For API details, see ListEnvironments in AWS Tools for PowerShell Cmdlet Reference.

The following code example shows how to use Get-C9EnvironmentMembershipList.

Tools for PowerShell

Example 1: This example gets information about environment members for the specified AWS Cloud9 development environment.

Get-C9EnvironmentMembershipList -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX

Output:

EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX LastAccess : 1/1/0001 12:00:00 AM Permissions : read-write UserArn : arn:aws:iam::123456789012:user/AnotherDemoUser UserId : AIDAJ3BA6O2FMJWCWXHEX EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX LastAccess : 1/1/0001 12:00:00 AM Permissions : owner UserArn : arn:aws:iam::123456789012:user/MyDemoUser UserId : AIDAJ3LOROMOUXTBSU6EX

Example 2: This example gets information about the owner of the specified AWS Cloud9 development environment.

Get-C9EnvironmentMembershipList -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX -Permission owner

Output:

EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX LastAccess : 1/1/0001 12:00:00 AM Permissions : owner UserArn : arn:aws:iam::123456789012:user/MyDemoUser UserId : AIDAJ3LOROMOUXTBSU6EX

Example 3: This example gets information about the specified environment member for multiple AWS Cloud9 development environments.

Get-C9EnvironmentMembershipList -UserArn arn:aws:iam::123456789012:user/MyDemoUser

Output:

EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX LastAccess : 1/17/2018 7:48:14 PM Permissions : owner UserArn : arn:aws:iam::123456789012:user/MyDemoUser UserId : AIDAJ3LOROMOUXTBSU6EX EnvironmentId : 1980b80e5f584920801c09086667f0EX LastAccess : 1/16/2018 11:21:24 PM Permissions : owner UserArn : arn:aws:iam::123456789012:user/MyDemoUser UserId : AIDAJ3LOROMOUXTBSU6EX

The following code example shows how to use Get-C9EnvironmentStatus.

Tools for PowerShell

Example 1: This example gets status information for the specified AWS Cloud9 development environment.

Get-C9EnvironmentStatus -EnvironmentId 349c86d4579e4e7298d500ff57a6b2EX

Output:

Message Status ------- ------ Environment is ready to use ready

The following code example shows how to use New-C9EnvironmentEC2.

Tools for PowerShell

Example 1: This example creates an AWS Cloud9 development environment with the specified settings, launches an Amazon Elastic Compute Cloud (Amazon EC2) instance, and then connects from the instance to the environment.

New-C9EnvironmentEC2 -Name my-demo-env -AutomaticStopTimeMinutes 60 -Description "My demonstration development environment." -InstanceType t2.micro -OwnerArn arn:aws:iam::123456789012:user/MyDemoUser -SubnetId subnet-d43a46EX

Output:

ffd88420d4824eeeaeaa8a04bfde8cEX

The following code example shows how to use New-C9EnvironmentMembership.

Tools for PowerShell

Example 1: This example adds the specified environment member to the specified AWS Cloud9 development environment.

New-C9EnvironmentMembership -UserArn arn:aws:iam::123456789012:user/AnotherDemoUser -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX -Permission read-write

Output:

EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX LastAccess : 1/1/0001 12:00:00 AM Permissions : read-write UserArn : arn:aws:iam::123456789012:user/AnotherDemoUser UserId : AIDAJ3BA6O2FMJWCWXHEX

The following code example shows how to use Remove-C9Environment.

Tools for PowerShell

Example 1: This example deletes the specified AWS Cloud9 development environment. If an Amazon EC2 instance is connected to the environment, also terminates the instance.

Remove-C9Environment -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX
  • For API details, see DeleteEnvironment in AWS Tools for PowerShell Cmdlet Reference.

The following code example shows how to use Remove-C9EnvironmentMembership.

Tools for PowerShell

Example 1: This example deletes the specified environment member from the specified AWS Cloud9 development environment.

Remove-C9EnvironmentMembership -UserArn arn:aws:iam::123456789012:user/AnotherDemoUser -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX

The following code example shows how to use Update-C9Environment.

Tools for PowerShell

Example 1: This example changes the specified settings of the specified existing AWS Cloud9 development environment.

Update-C9Environment -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX -Description "My changed demonstration development environment." -Name my-changed-demo-env
  • For API details, see UpdateEnvironment in AWS Tools for PowerShell Cmdlet Reference.

The following code example shows how to use Update-C9EnvironmentMembership.

Tools for PowerShell

Example 1: This example changes the settings of the specified existing environment member for the specified AWS Cloud9 development environment.

Update-C9EnvironmentMembership -UserArn arn:aws:iam::123456789012:user/AnotherDemoUser -EnvironmentId ffd88420d4824eeeaeaa8a04bfde8cEX -Permission read-only

Output:

EnvironmentId : ffd88420d4824eeeaeaa8a04bfde8cEX LastAccess : 1/1/0001 12:00:00 AM Permissions : read-only UserArn : arn:aws:iam::123456789012:user/AnotherDemoUser UserId : AIDAJ3BA6O2FMJWCWXHEX