AWS CodeStar examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with AWS CodeStar.
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 and cross-service examples.
Scenarios are code examples that show you how to accomplish a specific task by calling multiple functions within the same service.
Each example includes a link to GitHub, 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 associate-team-member
.
- Amazon CLI
-
To add a team member to a project
The following
associate-team-member
example makes theintern
user a viewer on the project with the specified ID.aws codestar associate-team-member \ --project-id
my-project
\ --user-arnarn:aws:iam::123456789012:user/intern
\ --project-roleViewer
This command produces no output.
-
For API details, see AssociateTeamMember
in Amazon CLI Command Reference.
-
The following code example shows how to use create-project
.
- Amazon CLI
-
To create a project
The following
create-project
example uses a JSON input file to create a CodeStar project.aws codestar create-project \ --cli-input-json
file://create-project.json
Contents of
create-project.json
:{ "name": "Custom Project", "id": "custom-project", "sourceCode": [ { "source": { "s3": { "bucketName": "codestar-artifacts", "bucketKey": "nodejs-function.zip" } }, "destination": { "codeCommit": { "name": "codestar-custom-project" } } } ], "toolchain": { "source": { "s3": { "bucketName": "codestar-artifacts", "bucketKey": "toolchain.yml" } }, "roleArn": "arn:aws:iam::123456789012:role/service-role/aws-codestar-service-role", "stackParameters": { "ProjectId": "custom-project" } } }
Output:
{ "id": "my-project", "arn": "arn:aws:codestar:us-east-2:123456789012:project/custom-project" }
For a tutorial that includes sample code and templates for a custom project, see Create a Project in Amazon CodeStar with the Amazon CLI<https://docs.aws.amazon.com/codestar/latest/userguide/cli-tutorial.html> in the Amazon CodeStar User Guide.
-
For API details, see CreateProject
in Amazon CLI Command Reference.
-
The following code example shows how to use create-user-profile
.
- Amazon CLI
-
To create a user profile
The following
create-user-profile
example creates a user profile for the IAM user with the specified ARN.aws codestar create-user-profile \ --user-arn
arn:aws:iam::123456789012:user/intern
\ --display-nameIntern
\ --email-addressintern@example.com
Output:
{ "userArn": "arn:aws:iam::123456789012:user/intern", "displayName": "Intern", "emailAddress": "intern@example.com", "sshPublicKey": "", "createdTimestamp": 1572552308.607, "lastModifiedTimestamp": 1572552308.607 }
-
For API details, see CreateUserProfile
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-project
.
- Amazon CLI
-
To delete a project
The following
delete-project
example deletes the specified project.aws codestar delete-project \ --project-id
my-project
Output:
{ "projectArn": "arn:aws:codestar:us-east-2:123456789012:project/my-project" }
-
For API details, see DeleteProject
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-user-profile
.
- Amazon CLI
-
To delete a user profile
The following
delete-user-profile
example deletes the user profile for the user with the specified ARN.aws codestar delete-user-profile \ --user-arn
arn:aws:iam::123456789012:user/intern
Output:
{ "userArn": "arn:aws:iam::123456789012:user/intern" }
-
For API details, see DeleteUserProfile
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-project
.
- Amazon CLI
-
To view a project
The following
describe-project
example retrieves details about the specified project.aws codestar describe-project \ --id
my-project
Output:
{ "name": "my project", "id": "my-project", "arn": "arn:aws:codestar:us-west-2:123456789012:project/my-project", "description": "My first CodeStar project.", "createdTimeStamp": 1572547510.128, "status": { "state": "CreateComplete" } }
-
For API details, see DescribeProject
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-user-profile
.
- Amazon CLI
-
To view a user profile
The following
describe-user-profile
example retrieves details about the user profile for the user with the specified ARN.aws codestar describe-user-profile \ --user-arn
arn:aws:iam::123456789012:user/intern
Output:
{ "userArn": "arn:aws:iam::123456789012:user/intern", "displayName": "Intern", "emailAddress": "intern@example.com", "sshPublicKey": "intern", "createdTimestamp": 1572552308.607, "lastModifiedTimestamp": 1572553495.47 }
-
For API details, see DescribeUserProfile
in Amazon CLI Command Reference.
-
The following code example shows how to use disassociate-team-member
.
- Amazon CLI
-
To remove a team member
The following
disassociate-team-member
example removes the user with the specified ARN from the projectmy-project
.aws codestar disassociate-team-member \ --project-id
my-project
\ --user-arnarn:aws:iam::123456789012:user/intern
This command produces no output.
-
For API details, see DisassociateTeamMember
in Amazon CLI Command Reference.
-
The following code example shows how to use list-projects
.
- Amazon CLI
-
To view projects
The following
list-projects
example retrieves a list of projects in the current Region.aws codestar list-projects
Output:
{ "projects": [ { "projectId": "intern-projects", "projectArn": "arn:aws:codestar:us-west-2:123456789012:project/intern-projects" }, { "projectId": "my-project", "projectArn": "arn:aws:codestar:us-west-2:123456789012:project/my-project" } ] }
-
For API details, see ListProjects
in Amazon CLI Command Reference.
-
The following code example shows how to use list-resources
.
- Amazon CLI
-
To view resources
The following
list-resources
example retrieves a list of resources for the specified project.aws codestar list-resources \ --id
my-project
Output:
{ "resources": [ { "id": "arn:aws:execute-api:us-east-2:123456789012:r3wxmplbv8" }, { "id": "arn:aws:codedeploy:us-east-2:123456789012:application:awscodestar-my-project-lambda-ServerlessDeploymentApplication-PF0LXMPL1KA0" }, { "id": "arn:aws:s3:::aws-codestar-us-east-2-123456789012-my-project-pipe" }, { "id": "arn:aws:lambda:us-east-2:123456789012:function:awscodestar-my-project-lambda-GetHelloWorld-16W3LVXMPLNNS" }, { "id": "arn:aws:cloudformation:us-east-2:123456789012:stack/awscodestar-my-project-lambda/b4904ea0-fc20-xmpl-bec6-029123b1cc42" }, { "id": "arn:aws:cloudformation:us-east-2:123456789012:stack/awscodestar-my-project/1b133f30-fc20-xmpl-a93a-0688c4290cb8" }, { "id": "arn:aws:iam::123456789012:role/CodeStarWorker-my-project-ToolChain" }, { "id": "arn:aws:iam::123456789012:policy/CodeStar_my-project_PermissionsBoundary" }, { "id": "arn:aws:s3:::aws-codestar-us-east-2-123456789012-my-project-app" }, { "id": "arn:aws:codepipeline:us-east-2:123456789012:my-project-Pipeline" }, { "id": "arn:aws:codedeploy:us-east-2:123456789012:deploymentgroup:my-project/awscodestar-my-project-lambda-GetHelloWorldDeploymentGroup-P7YWXMPLT0QB" }, { "id": "arn:aws:iam::123456789012:role/CodeStar-my-project-Execution" }, { "id": "arn:aws:iam::123456789012:role/CodeStarWorker-my-project-CodeDeploy" }, { "id": "arn:aws:codebuild:us-east-2:123456789012:project/my-project" }, { "id": "arn:aws:iam::123456789012:role/CodeStarWorker-my-project-CloudFormation" }, { "id": "arn:aws:codecommit:us-east-2:123456789012:Go-project" } ] }
-
For API details, see ListResources
in Amazon CLI Command Reference.
-
The following code example shows how to use list-tags-for-project
.
- Amazon CLI
-
To view tags for a project
The following
list-tags-for-project
example retrieves the tags attached to the specified project.aws codestar list-tags-for-project \ --id
my-project
Output:
{ "tags": { "Department": "Marketing", "Team": "Website" } }
-
For API details, see ListTagsForProject
in Amazon CLI Command Reference.
-
The following code example shows how to use list-team-members
.
- Amazon CLI
-
To view a list of team members
The following
list-team-members
example retrieves a list of users associated with the specified project.aws codestar list-team-members \ --project-id
my-project
Output:
{ "teamMembers": [ { "userArn": "arn:aws:iam::123456789012:user/admin", "projectRole": "Owner", "remoteAccessAllowed": false }, { "userArn": "arn:aws:iam::123456789012:user/intern", "projectRole": "Contributor", "remoteAccessAllowed": false } ] }
-
For API details, see ListTeamMembers
in Amazon CLI Command Reference.
-
The following code example shows how to use list-user-profiles
.
- Amazon CLI
-
To view a list of user profiles
The following
list-user-profiles
example retrieves a list of all user profiles in the current Region.aws codestar list-user-profiles
Output:
{ "userProfiles": [ { "userArn": "arn:aws:iam::123456789012:user/admin", "displayName": "me", "emailAddress": "me@example.com", "sshPublicKey": "" }, { "userArn": "arn:aws:iam::123456789012:user/intern", "displayName": "Intern", "emailAddress": "intern@example.com", "sshPublicKey": "intern" } ] }
-
For API details, see ListUserProfiles
in Amazon CLI Command Reference.
-
The following code example shows how to use tag-project
.
- Amazon CLI
-
To attach a tag to a project
The following
tag-project
example adds a tag namedDepartment
and a value ofMarketing
to the specified project.aws codestar tag-project \ --id
my-project
\ --tagsDepartment=Marketing
Output:
{ "tags": { "Department": "Marketing" } }
-
For API details, see TagProject
in Amazon CLI Command Reference.
-
The following code example shows how to use untag-project
.
- Amazon CLI
-
To remove a tag from a project
The following
untag-project
example removes any tag with a key name ofTeam
from the specifiec project.aws codestar untag-project \ --id
my-project
\ --tagsTeam
This command produces no output.
-
For API details, see UntagProject
in Amazon CLI Command Reference.
-
The following code example shows how to use update-project
.
- Amazon CLI
-
To update a project
The following
update-project
example adds a description to the specified project.aws codestar update-project \ --id
my-project
\ --description"My first CodeStar project"
This command produces no output.
-
For API details, see UpdateProject
in Amazon CLI Command Reference.
-
The following code example shows how to use update-team-member
.
- Amazon CLI
-
To modify a team member
The following
update-team-member
example makes the specified user a contributor on a project and grants them remote access to project resources.aws codestar update-team-member \ --project-id
my-project
\ --user-arnarn:aws:iam::123456789012:user/intern
\ --project-roleContributor
-
\ --remote-access-allowedOutput:
{ "userArn": "arn:aws:iam::123456789012:user/intern", "projectRole": "Contributor", "remoteAccessAllowed": true }
-
For API details, see UpdateTeamMember
in Amazon CLI Command Reference.
-
The following code example shows how to use update-user-profile
.
- Amazon CLI
-
To modify a user profile
The following
update-user-profile
example adds the specified SHH key to the specified user.aws codestar update-user-profile \ --ssh-public-key
intern
\ --user-arnarn:aws:iam::123456789012:user/intern
Output:
{ "userArn": "arn:aws:iam::123456789012:user/intern", "displayName": "Intern", "emailAddress": "intern@example.com", "sshPublicKey": "intern", "createdTimestamp": 1572552308.607, "lastModifiedTimestamp": 1572553495.47 }
-
For API details, see UpdateUserProfile
in Amazon CLI Command Reference.
-