AWS CodeStar contoh menggunakan AWS CLI - AWS Command Line Interface

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

AWS CodeStar contoh menggunakan AWS CLI

Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS Command Line Interface with AWS CodeStar.

Tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

Tindakan

Contoh kode berikut menunjukkan cara menggunakanassociate-team-member.

AWS CLI

Untuk menambahkan anggota tim ke proyek

associate-team-memberContoh berikut membuat intern pengguna penampil pada proyek dengan ID yang ditentukan.

aws codestar associate-team-member \ --project-id my-project \ --user-arn arn:aws:iam::123456789012:user/intern \ --project-role Viewer

Perintah ini tidak menghasilkan output.

Contoh kode berikut menunjukkan cara menggunakancreate-project.

AWS CLI

Untuk membuat proyek

create-projectContoh berikut menggunakan file JSON input untuk membuat CodeStar proyek.

aws codestar create-project \ --cli-input-json file://create-project.json

Isi dari 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" }

Untuk tutorial yang menyertakan contoh kode dan template untuk proyek kustom, lihat Membuat Proyek AWS CodeStar dengan AWS CLI < https://docs.aws.amazon.com/codestar/ latest/userguide/cli-tutorial.html> di Panduan Pengguna.AWS CodeStar

  • Untuk API detailnya, lihat CreateProjectdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakancreate-user-profile.

AWS CLI

Untuk membuat profil pengguna

create-user-profileContoh berikut membuat profil pengguna untuk IAM pengguna dengan yang ditentukanARN.

aws codestar create-user-profile \ --user-arn arn:aws:iam::123456789012:user/intern \ --display-name Intern \ --email-address intern@example.com

Output:

{ "userArn": "arn:aws:iam::123456789012:user/intern", "displayName": "Intern", "emailAddress": "intern@example.com", "sshPublicKey": "", "createdTimestamp": 1572552308.607, "lastModifiedTimestamp": 1572552308.607 }

Contoh kode berikut menunjukkan cara menggunakandelete-project.

AWS CLI

Untuk menghapus proyek

delete-projectContoh berikut menghapus proyek yang ditentukan.

aws codestar delete-project \ --project-id my-project

Output:

{ "projectArn": "arn:aws:codestar:us-east-2:123456789012:project/my-project" }
  • Untuk API detailnya, lihat DeleteProjectdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakandelete-user-profile.

AWS CLI

Untuk menghapus profil pengguna

delete-user-profileContoh berikut menghapus profil pengguna untuk pengguna dengan yang ditentukanARN.

aws codestar delete-user-profile \ --user-arn arn:aws:iam::123456789012:user/intern

Output:

{ "userArn": "arn:aws:iam::123456789012:user/intern" }

Contoh kode berikut menunjukkan cara menggunakandescribe-project.

AWS CLI

Untuk melihat proyek

describe-projectContoh berikut mengambil rincian tentang proyek yang ditentukan.

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" } }

Contoh kode berikut menunjukkan cara menggunakandescribe-user-profile.

AWS CLI

Untuk melihat profil pengguna

describe-user-profileContoh berikut mengambil rincian tentang profil pengguna untuk pengguna dengan yang ditentukanARN.

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 }

Contoh kode berikut menunjukkan cara menggunakandisassociate-team-member.

AWS CLI

Untuk menghapus anggota tim

disassociate-team-memberContoh berikut menghapus pengguna dengan yang ditentukan ARN dari proyekmy-project.

aws codestar disassociate-team-member \ --project-id my-project \ --user-arn arn:aws:iam::123456789012:user/intern

Perintah ini tidak menghasilkan output.

Contoh kode berikut menunjukkan cara menggunakanlist-projects.

AWS CLI

Untuk melihat proyek

list-projectsContoh berikut mengambil daftar proyek di Wilayah saat ini.

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" } ] }
  • Untuk API detailnya, lihat ListProjectsdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanlist-resources.

AWS CLI

Untuk melihat sumber daya

list-resourcesContoh berikut mengambil daftar sumber daya untuk proyek tertentu.

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" } ] }
  • Untuk API detailnya, lihat ListResourcesdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanlist-tags-for-project.

AWS CLI

Untuk melihat tag untuk proyek

list-tags-for-projectContoh berikut mengambil tag yang dilampirkan ke proyek yang ditentukan.

aws codestar list-tags-for-project \ --id my-project

Output:

{ "tags": { "Department": "Marketing", "Team": "Website" } }

Contoh kode berikut menunjukkan cara menggunakanlist-team-members.

AWS CLI

Untuk melihat daftar anggota tim

list-team-membersContoh berikut mengambil daftar pengguna yang terkait dengan proyek yang ditentukan.

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 } ] }

Contoh kode berikut menunjukkan cara menggunakanlist-user-profiles.

AWS CLI

Untuk melihat daftar profil pengguna

list-user-profilesContoh berikut mengambil daftar semua profil pengguna di Wilayah saat ini.

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" } ] }

Contoh kode berikut menunjukkan cara menggunakantag-project.

AWS CLI

Untuk melampirkan tag ke proyek

tag-projectContoh berikut menambahkan tag bernama Department dan nilai Marketing untuk proyek tertentu.

aws codestar tag-project \ --id my-project \ --tags Department=Marketing

Output:

{ "tags": { "Department": "Marketing" } }
  • Untuk API detailnya, lihat TagProjectdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanuntag-project.

AWS CLI

Untuk menghapus tag dari proyek

untag-projectContoh berikut menghapus tag apapun dengan nama kunci Team dari dari proyek specifiec.

aws codestar untag-project \ --id my-project \ --tags Team

Perintah ini tidak menghasilkan output.

  • Untuk API detailnya, lihat UntagProjectdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanupdate-project.

AWS CLI

Untuk memperbarui proyek

update-projectContoh berikut menambahkan deskripsi untuk proyek yang ditentukan.

aws codestar update-project \ --id my-project \ --description "My first CodeStar project"

Perintah ini tidak menghasilkan output.

  • Untuk API detailnya, lihat UpdateProjectdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanupdate-team-member.

AWS CLI

Untuk memodifikasi anggota tim

update-team-memberContoh berikut membuat pengguna tertentu kontributor pada proyek dan memberi mereka akses jarak jauh ke sumber daya proyek.

aws codestar update-team-member \ --project-id my-project \ --user-arn arn:aws:iam::123456789012:user/intern \ --project-role Contributor -\ --remote-access-allowed

Output:

{ "userArn": "arn:aws:iam::123456789012:user/intern", "projectRole": "Contributor", "remoteAccessAllowed": true }

Contoh kode berikut menunjukkan cara menggunakanupdate-user-profile.

AWS CLI

Untuk memodifikasi profil pengguna

update-user-profileContoh berikut menambahkan SHH kunci yang ditentukan untuk pengguna tertentu.

aws codestar update-user-profile \ --ssh-public-key intern \ --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 }