id
stringlengths 8
78
| source
stringclasses 743
values | chunk_id
int64 1
5.05k
| text
stringlengths 593
49.7k
|
---|---|---|---|
amazon-managed-blockchain-hyperledger-fabric-dev-007 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 7 | with basic information such as names and descriptions: • The open-source framework and version. This tutorial uses Hyperledger Fabric version 2.2. • The voting policy for proposals on the network. For more information, see Work with Proposals for a Hyperledger Fabric Network on Amazon Managed Blockchain (AMB). • The first member of the network, including the administrative user and administrative password that are used to authenticate to the member's certificate authority (CA). Additional Considerations 13 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Important Each member that is created accrues charges according to the membership rate for the network. For more information, see Amazon Managed Blockchain (AMB) Pricing. Create the network using the AWS CLI or AMB Access console according to the following instructions. It takes around 30 minutes for AMB Access to provision resources and bring the network online. To create a Hyperledger Fabric network using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Create private network. 3. Under Blockchain frameworks: a. b. Select the blockchain framework to use. This tutorial is based on Hyperledger Fabric version 2.2. Select the Network edition to use. The network edition determines attributes of the network, such as the maximum number of members, nodes per member, and transaction throughput. Different editions have different rates associated with the membership. For more information, see Amazon Managed Blockchain (AMB) Pricing. 4. Enter a Network name and description. 5. Under Voting Policy, choose the following: a. Enter the Approval threshold percentage along with the comparator, either Greater than or Greater than or equal to. For a proposal to pass, the Yes votes cast must meet this threshold before the vote duration expires. b. Enter the Proposal duration in hours. If enough votes are not cast within this duration to either approve or reject a proposal, the proposal status is EXPIRED, no further votes on this proposal are allowed, and the proposal does not pass. 6. Choose Next, and then, under Create member, do the following to define the first member for the network, which you own: a. Enter a Member name that will be visible to all members and an optional Description. Step 1: Create the Network and First Member 14 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide b. Under Hyperledger Fabric certificate authority (CA) configuration specify a username and password to be used as the administrator on the Hyperledger Fabric CA. Remember the user name and password. You need them later any time that you create users and resources that need to authenticate. c. Choose Next. 7. Review Network options and Member options, and then choose Create network and member. The Networks list shows the name and Network ID of the network you created, with a Status of Creating. It takes around 30 minutes for AMB Access to create your network, after which the Status is Available. To create a Hyperledger Fabric network using the AWS CLI Use the create-network command as shown in the following example. Consider the following: • The example shows HYPERLEDGER_FABRIC as the Framework and 2.2 as the FrameworkVersion. The FrameworkConfiguration properties for --network- configuration and --member-configuration options might be different for other frameworks and versions. • The AdminPassword must be at least 8 characters long and no more than 32 characters. It must contain at least one uppercase letter, one lowercase letter, and one digit. It cannot have a single quote(‘), double quote(“), forward slash(/), backward slash(\), @, percent sign (%), or a space. • The member name must not contain any special characters. • Remember the user name and password. You need them later any time you create users and resources that need to authenticate. [ec2-user@ip-192-0-2-17 ~]$ aws managedblockchain create-network \ --cli-input-json '{\"Name\":\"OurBlockchainNet\", \"Description\": \"OurBlockchainNetDesc\", \"Framework\":\"HYPERLEDGER_FABRIC\",\"FrameworkVersion \": \"2.2\", \"FrameworkConfiguration\": {\"Fabric\": {\"Edition\": \"STARTER \"}}, \"VotingPolicy\": {\"ApprovalThresholdPolicy\": {\"ThresholdPercentage\": 50, \"ProposalDurationInHours\": 24, \"ThresholdComparator\": \"GREATER_THAN \"}}, “MemberConfiguration”: {\"Name\":\"org1\", \"Description\":\"Org1 first member of network\", \"FrameworkConfiguration\":{\"Fabric\":\n{\"AdminUsername\": Step 1: Create the Network and First Member 15 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide \"MyAdminUser\",\"AdminPassword\":\"Password123\"}}, \"LogPublishingConfiguration\": {\"Fabric\":{\"CaLogs\":{\"Cloudwatch\": {\"Enabled\": true}}}}}}' The command returns the Network ID and the Member ID, as shown in the following example: { "NetworkId": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "MemberId": "m-K46ICRRXJRCGRNNS4ES4XUUS5A" } The Networks page on the console shows a Status of Available when the network is ready. Alternatively, you can use the list-networks command, as shown in the following example, to confirm the network status. aws managedblockchain list-networks The command returns information about the network, including an AVAILABLE status. { "Networks": [ { "Id": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "Name": "MyTestNetwork", "Description": "MyNetDescription", "Framework": "HYPERLEDGER_FABRIC", "FrameworkVersion": "2.2", "Status": "AVAILABLE", "CreationDate": 1541497086.888, } ] } Step 2: Create and Configure the Interface VPC Endpoint Now that the network is up and running in your VPC, you set up an interface VPC endpoint (AWS PrivateLink) for your member. This allows the Amazon EC2 instance that you |
amazon-managed-blockchain-hyperledger-fabric-dev-008 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 8 | of Available when the network is ready. Alternatively, you can use the list-networks command, as shown in the following example, to confirm the network status. aws managedblockchain list-networks The command returns information about the network, including an AVAILABLE status. { "Networks": [ { "Id": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "Name": "MyTestNetwork", "Description": "MyNetDescription", "Framework": "HYPERLEDGER_FABRIC", "FrameworkVersion": "2.2", "Status": "AVAILABLE", "CreationDate": 1541497086.888, } ] } Step 2: Create and Configure the Interface VPC Endpoint Now that the network is up and running in your VPC, you set up an interface VPC endpoint (AWS PrivateLink) for your member. This allows the Amazon EC2 instance that you use as a Hyperledger Fabric client to interact with the Hyperledger Fabric endpoints that Amazon Managed Blockchain (AMB) exposes for your member and network resources. For more information, see Interface VPC Endpoints (AWS PrivateLink) in the Amazon VPC User Guide. Applicable charges for interface VPC endpoints apply. For more information, see AWS PrivateLink Pricing. Step 2: Create an Endpoint 16 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide The AWS Identity and Access Management (IAM) principal (user) identity that you use must have sufficient IAM permissions to create an interface VPC endpoint in your AWS account. For more information, see Controlling Access - Creating and Managing VPC Endpoints in the Amazon VPC User Guide. You can create the interface VPC endpoint using a shortcut in the AMB Access console. To create an interface VPC endpoint using the AMB Access console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks, select your network from the list, and then choose View details. 3. Choose Create VPC endpoint. 4. Choose a VPC. 5. 6. For Subnets, choose a subnet from the list, and then choose additional subnets as necessary. For Security groups, choose an EC2 security group from the list, and then choose additional security groups as necessary. We recommend that you select the same security group that your framework client EC2 instance is associated with. 7. Choose Create. Step 3: Create a Peer Node in Your Membership Now that your network and the first member are up and running, you can use the AMB Access console or the AWS CLI to create a peer node. Your member's peer nodes interact with other members' peer nodes on the blockchain to query and update the ledger, and store a local copy of the ledger. Use one of the following procedures to create a peer node. To create a peer node using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks, select the network from the list, and then choose View details. 3. Select a Member from the list, and then choose Create peer node. 4. Choose configuration parameters for your peer node according to the guidelines in Work with Hyperledger Fabric Peer Nodes on AMB Access, and then choose Create peer node. Step 3: Create a Peer Node 17 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide To create a peer node using the AWS CLI • Use the create-node command, as shown in the following example. Replace the value of -- network-id, --member-id, and AvailabilityZone as appropriate. [ec2-user@ip-192-0-2-17 ~]$ aws managedblockchain create-node \ --node-configuration '{"InstanceType":"bc.t3.small","AvailabilityZone":"us- east-1a"}' \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-K46ICRRXJRCGRNNS4ES4XUUS5A The command returns output that includes the peer node's NodeID, as shown in the following example: { "NodeId": "nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y" } Step 4: Create an Amazon EC2 Instance and Set Up the Hyperledger Fabric Client To complete this step, you launch an Amazon EC2 instance using the Amazon Linux AMI. Consider the following requirements and recommendations when you create the Hyperledger Fabric client Amazon EC2 instance: • We recommend that you launch the client Amazon EC2 instance in the same VPC and using the same security group as the VPC Endpoint that you created in Step 2: Create and Configure the Interface VPC Endpoint. This simplifies connectivity between the Amazon EC2 instance and the Interface VPC Endpoint. • We recommend that the EC2 security group shared by the VPC Endpoint and the client Amazon EC2 instance have rules that allow all inbound and outbound traffic between members of the security group. This also simplifies connectivity. In addition, ensure that this security group or another security group associated with the client Amazon EC2 instance has a rule that allows inbound SSH connections from a source that includes your SSH client's IP address. For more information about security groups and required rules, see Configuring Security Groups for Amazon Managed Blockchain (AMB) Hyperledger Fabric. Step 4: Set Up a Client 18 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Make sure that the client Amazon EC2 instance is configured with an automatically assigned public IP address and that you can connect to it using SSH. For more information, see Getting Started with Amazon EC2 Linux Instances |
amazon-managed-blockchain-hyperledger-fabric-dev-009 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 9 | security group associated with the client Amazon EC2 instance has a rule that allows inbound SSH connections from a source that includes your SSH client's IP address. For more information about security groups and required rules, see Configuring Security Groups for Amazon Managed Blockchain (AMB) Hyperledger Fabric. Step 4: Set Up a Client 18 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Make sure that the client Amazon EC2 instance is configured with an automatically assigned public IP address and that you can connect to it using SSH. For more information, see Getting Started with Amazon EC2 Linux Instances and Connect to your Linux instance in the Amazon EC2 User Guide. • Make sure that the service role associated with the EC2 instance allows access to the Amazon S3 bucket where AMB Access certificates are stored and that it has required permissions for working with AMB Access resources. For more information, see Example IAM Role Permissions Policy for Hyperledger Fabric Client EC2 Instance. Note An AWS CloudFormation template to create a Hyperledger Fabric client is available in the amazon-managed-blockchain-client-templates repository on Github. For more information, see the readme.md in that repository. For more information about using AWS CloudFormation, see Getting Started in the AWS CloudFormation User Guide. Step 4.1: Install Packages Your Hyperledger Fabric client needs some packages and samples installed so that you can work with the Hyperledger Fabric resources. In this step, you install Go, Docker, Docker Compose, and some other utilities. You also create variables in the ~/.bash_profile for your development environment. These are prerequisites for installing and using Hyperledger tools. While connected to the Amazon EC2 instance using SSH, run the following commands to install utilities, install docker, and configure the Docker user to be the default user for the Amazon EC2 instance: sudo yum update -y sudo yum install jq telnet emacs docker libtool libtool-ltdl-devel git -y sudo service docker start sudo usermod -a -G docker ec2-user 4.1: Install Packages 19 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Log out and log in again for the usermod command to take effect. Run the following commands to install Docker Compose. sudo curl -L \ https://github.com/docker/compose/releases/download/1.20.0/docker-compose-`uname \ -s`-`uname -m` -o /usr/local/bin/docker-compose sudo chmod a+x /usr/local/bin/docker-compose Run the following commands to install golang. wget https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz tar -xzf go1.14.4.linux-amd64.tar.gz sudo mv go /usr/local sudo yum install git -y Use a text editor to set up variables such as GOROOT and GOPATH in your ~/.bashrc or ~/.bash_profile and save the updates. The following example shows entries in .bash_profile. # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin # GOROOT is the location where Go package is installed on your system export GOROOT=/usr/local/go # GOPATH is the location of your work directory export GOPATH=$HOME/go 4.1: Install Packages 20 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # CASERVICEENDPOINT is the endpoint to reach your member's CA # for example ca.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-1.amazonaws.com:30002 export CASERVICEENDPOINT=MyMemberCaEndpoint # ORDERER is the endpoint to reach your network's orderer # for example orderer.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 export ORDERER=MyNetworkOrdererEndpoint # Update PATH so that you can access the go binary system wide export PATH=$GOROOT/bin:$PATH export PATH=$PATH:/home/ec2-user/go/src/github.com/hyperledger/fabric-ca/bin After you update .bash_profile, apply the changes: source ~/.bash_profile After the installation, verify that you have the correct versions installed: • Docker–17.06.2-ce or later • Docker-compose–1.14.0 or later • Go–1.14.x To check the Docker version, run the following command: sudo docker version The command returns output similar to the following: Client: Version: 18.06.1-ce API version: 1.38 Go version: go1.14.4 Git commit: CommitHash Built: Tue Oct 2 18:06:45 2018 OS/Arch: linux/amd64 Experimental: false 4.1: Install Packages 21 Hyperledger Fabric Developer Guide Amazon Managed Blockchain (AMB) Server: Engine: Version: 18.06.1-ce API version: 1.38 (minimum version 1.12) Go version: go1.14.4 Git commit: e68fc7a/18.06.1-ce Built: Tue Oct 2 18:08:26 2018 OS/Arch: linux/amd64 Experimental: false To check the version of Docker Compose, run the following command: sudo /usr/local/bin/docker-compose version The command returns output similar to the following: docker-compose version 1.22.0, build f46880fe docker-py version: 3.4.1 CPython version: 3.6.6 OpenSSL version: OpenSSL 1.1.0f 25 May 2017 To check the version of go, run the following command: go version The command returns output similar to the following: go version go1.14.4 linux/amd64 Step 4.2: Set Up the Hyperledger Fabric CA Client In this step, you verify that you can connect to the Hyperledger Fabric CA using the VPC endpoint you configured in Step 2: Create and Configure the Interface VPC Endpoint. You then install the Hyperledger Fabric CA client. The Fabric CA issues certificates to administrators and network peers. To verify connectivity to the Hyperledger Fabric CA, you need the CAEndpoint. Use the get- member command to get the CA endpoint for your member, as shown in the following example. Replace the values of |
amazon-managed-blockchain-hyperledger-fabric-dev-010 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 10 | similar to the following: go version go1.14.4 linux/amd64 Step 4.2: Set Up the Hyperledger Fabric CA Client In this step, you verify that you can connect to the Hyperledger Fabric CA using the VPC endpoint you configured in Step 2: Create and Configure the Interface VPC Endpoint. You then install the Hyperledger Fabric CA client. The Fabric CA issues certificates to administrators and network peers. To verify connectivity to the Hyperledger Fabric CA, you need the CAEndpoint. Use the get- member command to get the CA endpoint for your member, as shown in the following example. Replace the values of --network-id and --member-id with the values returned in Step 1: Create the Network and First Member. 4.2: Set Up the Fabric CA Client 22 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide aws managedblockchain get-member \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-K46ICRRXJRCGRNNS4ES4XUUS5A Use curl or telnet to verify that the endpoint resolves. In the following example, the value of the variable $CASERVICEENDPOINT is the CAEndpoint returned by the get-member command. curl https://$CASERVICEENDPOINT/cainfo -k The command should return output similar to the following: {"result": {"CAName":"abcd1efghijkllmn5op3q52rst","CAChain":"LongStringOfCharacters","Version":"1.4.7- snapshot-"} ,"errors":[],"messages":[],"success":true} Note that Hyperledger Fabric v2.2 networks should use version 1.4 of the CA client. Alternatively, you can connect to the Fabric CA using Telnet as shown in the following example. Use the same endpoint in the curl example, but separate the endpoint and the port as shown in the following example. telnet CaEndpoint-Without-Port CaPort The command should return output similar to the following: Trying 10.0.1.228... Connected to ca.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-1.amazonaws.com. Escape character is '^]'. If you are unable to connect to the Fabric CA, double-check your network settings to ensure that the client Amazon EC2 instance has connectivity with the VPC Endpoint. In particular, ensure that the security groups associated with both the VPC Endpoint and the client Amazon EC2 instance have inbound and outbound rules that allow traffic between them. Now that you have verified that you can connect to the Hyperledger Fabric CA, run the following commands to configure the CA client. 4.2: Set Up the Fabric CA Client 23 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Note If you are working with Hyperledger Fabric v1.2 networks, you need to install and build the correct client version, which is available at https://github.com/hyperledger/fabric-ca/ releases/download/v1.2.1/hyperledger-fabric-ca-linux-amd64-1.2.1.tar.gz. mkdir -p /home/ec2-user/go/src/github.com/hyperledger/fabric-ca cd /home/ec2-user/go/src/github.com/hyperledger/fabric-ca wget https://github.com/hyperledger/fabric-ca/releases/download/v1.4.7/hyperledger- fabric-ca-linux-amd64-1.4.7.tar.gz tar -xzf hyperledger-fabric-ca-linux-amd64-1.4.7.tar.gz Step 4.3: Clone the Samples Repository Note If you are working with Hyperledger Fabric v1.2 or v1.4 networks, use --branch v1.2.0 or --branch v1.4.7 instead of --branch v2.2.3 in the following commmands. cd /home/ec2-user git clone --branch v2.2.3 https://github.com/hyperledger/fabric-samples.git Step 4.4: Configure and Run Docker Compose to Start the Hyperledger Fabric CLI Use a text editor to create a configuration file for Docker Compose named docker-compose- cli.yaml in the /home/ec2-user directory, which you use to run the Hyperledger Fabric CLI. You use this CLI to interact with peer nodes that your member owns. Copy the following contents into the file and replace the placeholder values according to the following guidance: 4.3: Clone Samples 24 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • MyMemberID is the MemberID returned by the aws managedblockchain list-members AWS CLI command and shown on the member details page of the AMB Access console—for example, m-K46ICRRXJRCGRNNS4ES4XUUS5A. • MyPeerNodeEndpoint is the PeerEndpoint returned by the aws managedblockchain get-node command and listed on the node details page of the AMB Access console—for example, nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-1.amazonaws.com:30003. When you subsequently use the cli container to run commands—for example, docker exec cli peer channel create—you can use the -e option to override an environment variable that you establish in the docker-compose-cli.yaml file. Note If you are working with Hyperledger Fabric v1.2 or v1.4 networks, use image: hyperledger/fabric-tools:1.2 or image: hyperledger/fabric-tools:1.4 in the following example instead of image: hyperledger/fabric-tools:2.2.3. In addition for v1.2, use CORE_LOGGING_LEVEL=info instead of FABRIC_LOGGING_SPEC=info. version: '2' services: cli: container_name: cli image: hyperledger/fabric-tools:2.2.3 tty: true environment: - GOPATH=/opt/gopath - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock - FABRIC_LOGGING_SPEC=info # Set logging level to debug for more verbose logging - CORE_PEER_ID=cli - CORE_CHAINCODE_KEEPALIVE=10 - CORE_PEER_TLS_ENABLED=true - CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem - CORE_PEER_LOCALMSPID=MyMemberID - CORE_PEER_MSPCONFIGPATH=/opt/home/admin-msp - CORE_PEER_ADDRESS=MyPeerNodeEndpoint working_dir: /opt/home 4.4: Start the Hyperledger Fabric CLI 25 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide command: /bin/bash volumes: - /var/run/:/host/var/run/ - /home/ec2-user/fabric-samples/chaincode:/opt/gopath/src/github.com/ - /home/ec2-user:/opt/home Run the following command to start the Hyperledger Fabric peer CLI container: docker-compose -f docker-compose-cli.yaml up -d If you restarted or logged out and back in after the usermod command in Step 4.1: Install Packages, you shouldn't need to run this command with sudo. If the command fails, you can log out and log back in. Alternatively, you can run the command using sudo, as shown in the following example: sudo /usr/local/bin/docker-compose -f docker-compose-cli.yaml up -d Step 5: Enroll an Administrative User In this step, you use a pre-configured certificate to enroll a user with administrative |
amazon-managed-blockchain-hyperledger-fabric-dev-011 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 11 | - /home/ec2-user/fabric-samples/chaincode:/opt/gopath/src/github.com/ - /home/ec2-user:/opt/home Run the following command to start the Hyperledger Fabric peer CLI container: docker-compose -f docker-compose-cli.yaml up -d If you restarted or logged out and back in after the usermod command in Step 4.1: Install Packages, you shouldn't need to run this command with sudo. If the command fails, you can log out and log back in. Alternatively, you can run the command using sudo, as shown in the following example: sudo /usr/local/bin/docker-compose -f docker-compose-cli.yaml up -d Step 5: Enroll an Administrative User In this step, you use a pre-configured certificate to enroll a user with administrative permissions to your member's certificate authority (CA). To do this, you must create a certificate file. You also need the endpoint for the CA of your member, and the user name and password for the user that you created in Step 1: Create the Network and First Member. Step 5.1: Create the Certificate File Run the following command to copy the managedblockchain-tls-chain.pem to the /home/ ec2-user directory. Replace MyRegion with the AWS Region you are using—for example, us- east-1. aws s3 cp s3://MyRegion.managedblockchain/etc/managedblockchain-tls-chain.pem /home/ ec2-user/managedblockchain-tls-chain.pem If the command fails with a permissions error, ensure that a service role associated with the EC2 instance allows access to the Amazon S3 bucket location. For more information see Example IAM Role Permissions Policy for Hyperledger Fabric Client EC2 Instance. Run the following command to test that you copied the contents to the file correctly: Step 5: Enroll the Member Admin 26 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide openssl x509 -noout -text -in /home/ec2-user/managedblockchain-tls-chain.pem The command should return the contents of the certificate in human-readable format. Step 5.2: Enroll the Administrative User AMB Access registers the user identity that you specified when you created the member as an administrator. In Hyperledger Fabric, this user is known as the bootstrap identity because the identity is used to enroll itself. To enroll, you need the CA endpoint, as well as the user name and password for the administrator that you created in Step 1: Create the Network and First Member. For information about registering other user identities as administrators before you enroll them, see Register and Enroll a Hyperledger Fabric Admin. Use the get-member command to get the CA endpoint for your membership as shown in the following example. Replace the values of --network-id and --member-id with the values returned in Step 1: Create the Network and First Member. aws managedblockchain get-member \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-K46ICRRXJRCGRNNS4ES4XUUS5A The command returns information about the initial member that you created in the network, as shown in the following example. Make a note of the CaEndpoint. You also need the AdminUsername and password that you created along with the network. The command returns output similar to the following: { "Member": { "NetworkId": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "Status": "AVAILABLE", "Description": "MyNetDescription", "FrameworkAttributes": { "Fabric": { "CaEndpoint": "ca.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-1.amazonaws.com:30002", "AdminUsername": "Example-AdminUser" } }, "StatusReason": "Network member created successfully", 5.2 Enroll the Admin 27 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "CreationDate": 1542255358.74, "Id": "m-K46ICRRXJRCGRNNS4ES4XUUS5A", "Name": "org1" } } Use the CA endpoint, administrator profile, and the certificate file to enroll the member administrator using the fabric-ca-client enroll command, as shown in the following example: fabric-ca-client enroll \ -u 'https://${AdminUsername}:${AdminPassword}@$CASERVICEENDPOINT' \ --tls.certfiles /home/ec2-user/managedblockchain-tls-chain.pem -M /home/ec2-user/admin- msp To use this command, you will need to set the following environment variables: • AdminUsername — The admin username. • AdminPassword — The admin password. Warning Always use variables in your code to pass user credentials. For more information, see Move hard-coded credentials to AWS Secrets Manager An example command with fictitious administrator name, password, and endpoint is shown in the following example: fabric-ca-client enroll \ -u https://Example-AdminUser:Example-Password123@ca.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-1.amazonaws.com:30002 \ --tls.certfiles /home/ec2-user/managedblockchain-tls-chain.pem -M /home/ec2-user/admin- msp The command returns output similar to the following: 2018/11/16 02:21:40 [INFO] Created a default configuration file at /home/ec2- user/.fabric-ca-client/fabric-ca-client-config.yaml 5.2 Enroll the Admin 28 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide 2018/11/16 02:21:40 [INFO] TLS Enabled 2018/11/16 02:21:40 [INFO] generating key: &{A:ecdsa S:256} 2018/11/16 02:21:40 [INFO] encoded CSR 2018/11/16 02:21:40 [INFO] Stored client certificate at /home/ec2-user/admin-msp/ signcerts/cert.pem 2018/11/16 02:21:40 [INFO] Stored root CA certificate at /home/ec2-user/admin-msp/ cacerts/ca-abcd1efghijkllmn5op3q52rst-uqz2f2xakfd7vcfewqhckr7q5m-managedblockchain-us- east-1-amazonaws-com-30002.pem Important It may take a minute or two after you enroll for you to be able to use your administrator certificate to create a channel with the ordering service. Step 5.3: Copy Certificates for the MSP In Hyperledger Fabric, the Membership Service Provider (MSP) identifies which root CAs and intermediate CAs are trusted to define the members of a trust domain. Certificates for the administrator's MSP are in /home/ec2-user/admin-msp in this tutorial. Because this MSP is for the member administrator, copy the certificates from signcerts to admincerts as shown in the following example. The example assumes you are in the /home/ec2-user directory when running the command. cp -r /home/ec2-user/admin-msp/signcerts admin-msp/admincerts Step |
amazon-managed-blockchain-hyperledger-fabric-dev-012 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 12 | for you to be able to use your administrator certificate to create a channel with the ordering service. Step 5.3: Copy Certificates for the MSP In Hyperledger Fabric, the Membership Service Provider (MSP) identifies which root CAs and intermediate CAs are trusted to define the members of a trust domain. Certificates for the administrator's MSP are in /home/ec2-user/admin-msp in this tutorial. Because this MSP is for the member administrator, copy the certificates from signcerts to admincerts as shown in the following example. The example assumes you are in the /home/ec2-user directory when running the command. cp -r /home/ec2-user/admin-msp/signcerts admin-msp/admincerts Step 6: Create a Hyperledger Fabric Channel In Hyperledger Fabric, a ledger exists in the scope of a channel. The ledger can be shared across the entire network if every member is operating on a common channel. A channel also can be privatized to include only a specific set of participants. Members can be in your AWS account, or they can be members that you invite from other AWS accounts. In this step, you set up a basic channel. Later on in the tutorial, in Step 8: Invite Another AWS Account to be a Member and Create a Multi-Member Channel, you go through a similar process to set up a channel that includes another member. Wait a minute or two for the administrative permissions from previous steps to propagate, and then perform these tasks to create a channel. 5.3: Copy Certificates 29 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Note All Hyperledger Fabric networks on AMB Access support a maximum of 8 channels per network, regardless of network edition. Step 6.1: Create configtx for Hyperledger Fabric Channel Creation The configtx.yaml file contains details of the channel configuration. For more information, see Channel Configuration (configtx) in the Hyperledger Fabric documentation. This configtx.yaml enables application features associated with Hyperledger Fabric 2.2. It is not compatible with Hyperledger Fabric 1.2 or 1.4. For a configtx.yaml compatible with Hyperledger Fabric 1.2 or 1.4, see Work with Channels. Use a text editor to create a file with the following contents and save it as configtx.yaml on your Hyperledger Fabric client. Note the following placeholders and values. • Replace MemberID with the MemberID you returned previously. For example m- K46ICRRXJRCGRNNS4ES4XUUS5A. • The MSPDir is set to the same directory location, /opt/home/admin-msp, that you established using the CORE_PEER_MSPCONFIGPATH environment variable in the Docker container for the Hyperledger Fabric CLI in step 4.4. Important This file is sensitive. Artifacts from pasting can cause the file to fail with marshalling errors. We recommend using emacs to edit it. You can also use VI, but before using VI, enter :set paste, press i to enter insert mode, paste the contents, press escape, and then enter :set nopaste before saving. ################################################################################ # # ORGANIZATIONS # # This section defines the organizational identities that can be referenced # in the configuration profiles. 6.1: Create configtx 30 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # ################################################################################ Organizations: # Org1 defines an MSP using the sampleconfig. It should never be used # in production but may be used as a template for other definitions. - &Org1 # Name is the key by which this org will be referenced in channel # configuration transactions. # Name can include alphanumeric characters as well as dots and dashes. Name: MemberID # ID is the key by which this org's MSP definition will be referenced. # ID can include alphanumeric characters as well as dots and dashes. ID: MemberID # SkipAsForeign can be set to true for org definitions which are to be # inherited from the orderer system channel during channel creation. This # is especially useful when an admin of a single org without access to the # MSP directories of the other orgs wishes to create a channel. Note # this property must always be set to false for orgs included in block # creation. SkipAsForeign: false Policies: &Org1Policies Readers: Type: Signature Rule: "OR('Org1.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.peer', 'Org1.client')" Writers: Type: Signature Rule: "OR('Org1.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.client')" Admins: Type: Signature Rule: "OR('Org1.admin')" # MSPDir is the filesystem path which contains the MSP configuration. MSPDir: /opt/home/admin-msp # AnchorPeers defines the location of peers which can be used for # cross-org gossip communication. Note, this value is only encoded in # the genesis block in the Application section context. AnchorPeers: - Host: 127.0.0.1 Port: 7051 6.1: Create configtx 31 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide ################################################################################ # # CAPABILITIES # # This section defines the capabilities of |
amazon-managed-blockchain-hyperledger-fabric-dev-013 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 13 | the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.client')" Admins: Type: Signature Rule: "OR('Org1.admin')" # MSPDir is the filesystem path which contains the MSP configuration. MSPDir: /opt/home/admin-msp # AnchorPeers defines the location of peers which can be used for # cross-org gossip communication. Note, this value is only encoded in # the genesis block in the Application section context. AnchorPeers: - Host: 127.0.0.1 Port: 7051 6.1: Create configtx 31 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide ################################################################################ # # CAPABILITIES # # This section defines the capabilities of fabric network. This is a new # concept as of v1.1.0 and should not be utilized in mixed networks with # v1.0.x peers and orderers. Capabilities define features which must be # present in a fabric binary for that binary to safely participate in the # fabric network. For instance, if a new MSP type is added, newer binaries # might recognize and validate the signatures from this type, while older # binaries without this support would be unable to validate those # transactions. This could lead to different versions of the fabric binaries # having different world states. Instead, defining a capability for a channel # informs those binaries without this capability that they must cease # processing transactions until they have been upgraded. For v1.0.x if any # capabilities are defined (including a map with all capabilities turned off) # then the v1.0.x peer will deliberately crash. # ################################################################################ Capabilities: # Channel capabilities apply to both the orderers and the peers and must be # supported by both. # Set the value of the capability to true to require it. # Note that setting a later Channel version capability to true will also # implicitly set prior Channel version capabilities to true. There is no need # to set each version capability to true (prior version capabilities remain # in this sample only to provide the list of valid values). Channel: &ChannelCapabilities # V2.0 for Channel is a catchall flag for behavior which has been # determined to be desired for all orderers and peers running at the v2.0.0 # level, but which would be incompatible with orderers and peers from # prior releases. # Prior to enabling V2.0 channel capabilities, ensure that all # orderers and peers on a channel are at v2.0.0 or later. V2_0: true # Orderer capabilities apply only to the orderers, and may be safely # used with prior release peers. # Set the value of the capability to true to require it. Orderer: &OrdererCapabilities # V1.1 for Orderer is a catchall flag for behavior which has been # determined to be desired for all orderers running at the v1.1.x # level, but which would be incompatible with orderers from prior releases. # Prior to enabling V2.0 orderer capabilities, ensure that all # orderers on a channel are at v2.0.0 or later. 6.1: Create configtx 32 Amazon Managed Blockchain (AMB) V2_0: true Hyperledger Fabric Developer Guide # Application capabilities apply only to the peer network, and may be safely # used with prior release orderers. # Set the value of the capability to true to require it. # Note that setting a later Application version capability to true will also # implicitly set prior Application version capabilities to true. There is no need # to set each version capability to true (prior version capabilities remain # in this sample only to provide the list of valid values). Application: &ApplicationCapabilities # V2.0 for Application enables the new non-backwards compatible # features and fixes of fabric v2.0. # Prior to enabling V2.0 orderer capabilities, ensure that all # orderers on a channel are at v2.0.0 or later. V2_0: true ################################################################################ # # CHANNEL # # This section defines the values to encode into a config transaction or # genesis block for channel related parameters. # ################################################################################ Channel: &ChannelDefaults # Policies defines the set of policies at this level of the config tree # For Channel policies, their canonical path is # /Channel/<PolicyName> Policies: # Who may invoke the 'Deliver' API Readers: Type: ImplicitMeta Rule: "ANY Readers" # Who may invoke the 'Broadcast' API Writers: Type: ImplicitMeta Rule: "ANY Writers" # By default, who may modify elements at this config level Admins: Type: ImplicitMeta Rule: "MAJORITY Admins" # Capabilities describes the channel level capabilities, see the # dedicated Capabilities section elsewhere in this file for a full # description Capabilities: <<: *ChannelCapabilities 6.1: Create configtx 33 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide ################################################################################ # # APPLICATION # # This section defines the values to encode into a config transaction or # genesis block for application-related parameters. # ################################################################################ Application: &ApplicationDefaults # Organizations is the list of orgs which are defined as participants on # |
amazon-managed-blockchain-hyperledger-fabric-dev-014 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 14 | ImplicitMeta Rule: "ANY Writers" # By default, who may modify elements at this config level Admins: Type: ImplicitMeta Rule: "MAJORITY Admins" # Capabilities describes the channel level capabilities, see the # dedicated Capabilities section elsewhere in this file for a full # description Capabilities: <<: *ChannelCapabilities 6.1: Create configtx 33 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide ################################################################################ # # APPLICATION # # This section defines the values to encode into a config transaction or # genesis block for application-related parameters. # ################################################################################ Application: &ApplicationDefaults # Organizations is the list of orgs which are defined as participants on # the application side of the network Organizations: # Policies defines the set of policies at this level of the config tree # For Application policies, their canonical path is # /Channel/Application/<PolicyName> Policies: &ApplicationDefaultPolicies LifecycleEndorsement: Type: ImplicitMeta Rule: "ANY Readers" Endorsement: Type: ImplicitMeta Rule: "ANY Readers" Readers: Type: ImplicitMeta Rule: "ANY Readers" Writers: Type: ImplicitMeta Rule: "ANY Writers" Admins: Type: ImplicitMeta Rule: "MAJORITY Admins" Capabilities: <<: *ApplicationCapabilities ################################################################################ # # PROFILES # # Different configuration profiles may be encoded here to be specified as # parameters to the configtxgen tool. The profiles which specify consortiums # are to be used for generating the orderer genesis block. With the correct # consortium members defined in the orderer genesis block, channel creation # requests may be generated with only the org member names and a consortium # name. 6.1: Create configtx 34 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # ################################################################################ Profiles: OneOrgChannel: <<: *ChannelDefaults Consortium: AWSSystemConsortium Application: <<: *ApplicationDefaults Organizations: - <<: *Org1 Run the following command to generate the configtx peer block: docker exec cli configtxgen \ -outputCreateChannelTx /opt/home/mychannel.pb \ -profile OneOrgChannel -channelID mychannel \ --configPath /opt/home/ Important Hyperledger Fabric 2.2 requires that a channel ID contain only lowercase ASCII alphanumeric characters, dots (.), and dashes (-). It must start with a letter, and must be fewer than 250 characters. Step 6.2: Set Environment Variables for the Orderer Set the $ORDERER environment variable for convenience. Replace orderer.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 with the OrderingServiceEndpoint returned by the aws managedblockchain get- network command and listed on the network details page of the AMB Access console. Replace MyRegion with the AWS Region you are using—for example, us-east-1. export ORDERER=orderer.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 This variable must be exported each time you log out of the client. To persist the variable across sessions, add the export statement to your ~/.bash_profile as shown in the following example. # .bash_profile 6.2: Set an Environment Variable for the Orderer 35 Amazon Managed Blockchain (AMB) ...other configurations Hyperledger Fabric Developer Guide export ORDERER=orderer.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 After updating .bash_profile, apply the changes: source ~/.bash_profile Step 6.3: Create the Channel Run the following command to create a channel using the variables that you established and the configtx peer block that you created: docker exec cli peer channel create -c mychannel \ -f /opt/home/mychannel.pb -o $ORDERER \ --cafile /opt/home/managedblockchain-tls-chain.pem --tls Important It may take a minute or two after you enroll an administrative user for you to be able to use your administrator certificate to create a channel with the ordering service. Step 6.4: Join Your Peer Node to the Channel Run the following command to join the peer node that you created earlier to the channel: docker exec cli peer channel join -b mychannel.block \ -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls Step 7: Install and Run Chaincode In this section, you create and install a package for golang sample chaincode on your peer node. You also approve, commit, and verify the chaincode. You then use the chaincode's init command to initialize values attributed to entities a and b in the ledger, followed by the query command to confirm that initialization was successful. Next, 6.3: Create the Channel 36 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide you use the chaincode's invoke command to transfer 10 units from a to b in the ledger. Finally, you use the chaincode's query command again to confirm that the value attributed to a was decremented by 10 units in the ledger. Step 7.1: Install Vendor Dependencies Run the following commands to enable vendoring for the Go module dependencies of your example chaincode. sudo chown -R ec2-user:ec2-user fabric-samples/ cd fabric-samples/chaincode/abstore/go/ GO111MODULE=on go mod vendor cd - Step 7.2: Create the Chaincode Package Run the following command to create the example chaincode package. docker exec cli peer lifecycle chaincode package ./abstore.tar.gz \ --path fabric-samples/chaincode/abstore/go/ \ --label abstore_1 Step 7.3: Install the Package Run the following command to install the chaincode package on the peer node. docker exec cli peer lifecycle chaincode install abstore.tar.gz Step 7.4: Verify the Package Run the following command to verify that the chaincode package is installed on the peer node. docker exec cli peer lifecycle chaincode queryinstalled The command returns the following if the package is installed successfully. Installed |
amazon-managed-blockchain-hyperledger-fabric-dev-015 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 15 | mod vendor cd - Step 7.2: Create the Chaincode Package Run the following command to create the example chaincode package. docker exec cli peer lifecycle chaincode package ./abstore.tar.gz \ --path fabric-samples/chaincode/abstore/go/ \ --label abstore_1 Step 7.3: Install the Package Run the following command to install the chaincode package on the peer node. docker exec cli peer lifecycle chaincode install abstore.tar.gz Step 7.4: Verify the Package Run the following command to verify that the chaincode package is installed on the peer node. docker exec cli peer lifecycle chaincode queryinstalled The command returns the following if the package is installed successfully. Installed chaincodes on peer: Package ID: MyPackageID, Label: abstore_1 7.1: Install Vendor Dependencies 37 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Step 7.5: Approve the Chaincode Run the following commands to approve the chaincode definition for your organization. Replace MyPackageID with the Package ID value returned in the previous step Step 7.4: Verify the Package. export CC_PACKAGE_ID=MyPackageID docker exec cli peer lifecycle chaincode approveformyorg \ --orderer $ORDERER --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ --channelID mychannel --name mycc --version v0 --sequence 1 --package-id $CC_PACKAGE_ID Step 7.6: Check Commit Readiness Run the following command to check whether the chaincode definition is ready to be committed on the channel. docker exec cli peer lifecycle chaincode checkcommitreadiness \ --orderer $ORDERER --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ --channelID mychannel --name mycc --version v0 --sequence 1 The command returns true if the chaincode is ready to be committed. Chaincode definition for chaincode 'mycc', version 'v0', sequence '1' on channel 'mychannel' approval status by org: m-LVQMIJ75CNCUZATGHLDP24HUHM: true Step 7.7: Commit the Chaincode Run the following command to commit the chaincode definition on the channel. docker exec cli peer lifecycle chaincode commit \ --orderer $ORDERER --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ --channelID mychannel --name mycc --version v0 --sequence 1 Step 7.8: Verify the Chaincode You might have to wait a minute or two for the commit to propagate to the peer node. Run the following command to verify that the chaincode is committed. 7.5: Approve Chaincode 38 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide docker exec cli peer lifecycle chaincode querycommitted \ --channelID mychannel The command returns the following if the chaincode is committed successfully. Committed chaincode definitions on channel 'mychannel': Name: mycc, Version: v0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc Step 7.9: Initialize the Chaincode Run the following command to initialize the chaincode. docker exec cli peer chaincode invoke \ --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ --channelID mychannel \ --name mycc -c '{"Args":["init", "a", "100", "b", "200"]}' The command returns the following when the chaincode is initialized. 2021-12-20 19:23:05.434 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 0ad Chaincode invoke successful. result: status:200 Step 7.10: Query the Chaincode You might need to wait a brief moment for the initialization from the previous command to complete before you run the following command to query a value. docker exec cli peer chaincode query \ --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ --channelID mychannel \ --name mycc -c '{"Args":["query", "a"]}' The command should return the value of a, which you initialized with a value of 100. Step 7.11: Invoke the Chaincode In the previous steps, you initialized the key a with a value of 100 and queried to verify. Using the invoke command in the following example, you subtract 10 from that initial value. 7.9: Initialize Chaincode 39 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide docker exec cli peer chaincode invoke \ --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ --channelID mychannel \ --name mycc -c '{"Args":["invoke", "a", "b", "10"]}' The command returns the following when the chaincode is invoked. 2021-12-20 19:23:22.977 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 0ad Chaincode invoke successful. result: status:200 Lastly, you again query the value of a using the following command. docker exec cli peer chaincode query \ --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ --channelID mychannel \ --name mycc -c '{"Args":["query", "a"]}' The command should return the new value 90. Step 8: Invite Another AWS Account to be a Member and Create a Multi-Member Channel Now that you have a Hyperledger Fabric network set up using Amazon Managed Blockchain (AMB), with an initial member in your AWS account and a VPC endpoint with a service name, you are ready to invite additional members. You invite additional members by creating a proposal for an invitation that existing members vote on. Since the blockchain network at this point consists of only one member, the first member always has the only vote on the invitation proposal for the second member. In the steps that follow, the network creator has an initial member named org1 and the invited member is named org2. For proof of concept, you can create an invitation proposal for an additional member in the same AWS account that you used to create the network, or you can create an invitation proposal for a different AWS account. After the invitation proposal is approved, |
amazon-managed-blockchain-hyperledger-fabric-dev-016 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 16 | an invitation that existing members vote on. Since the blockchain network at this point consists of only one member, the first member always has the only vote on the invitation proposal for the second member. In the steps that follow, the network creator has an initial member named org1 and the invited member is named org2. For proof of concept, you can create an invitation proposal for an additional member in the same AWS account that you used to create the network, or you can create an invitation proposal for a different AWS account. After the invitation proposal is approved, the invited account can create a member. Invited members are free to reject the invitation or ignore it until the invitation proposal expires. The invited account needs the network ID and VPC endpoint service name of the blockchain network to create a member. For more information, see Work with Invitations. The invited account also needs to fulfill the prerequisites listed in Prerequisites and Considerations. Step 8: Invite a Member and Create a Multi-Member Channel 40 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Step 8.1: Create an Invitation Proposal Create a proposal to invite an AWS account to create a member and join the network according to the following procedures. You need the AWS account ID of the member you want to invite. You can also invite your own account to create an additional member. If you are using the CLI, you also need the Network ID and Member ID that you created in Step 1: Create the Network and First Member. To create an invitation proposal using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. From the navigation pane, choose Networks, and then choose the network to which you want to invite an AWS account. 3. Choose Proposals and then choose Propose invitation. 4. For Submit proposal as, choose the member in your account that submits the proposal. Note The member who submits the proposal must also vote on it. A Yes vote is not automatically assumed. 5. 6. Enter an optional Description . The description appears to other members. It's a good way to communicate key points or a reminder about the proposal before they vote. For each AWS account that you want to invite, enter the account number in the space provided. Choose Add to enter additional accounts. 7. Choose Create. To create an invitation proposal using the AWS CLI • Type a command similar to the following. Replace the value of Principal with the AWS account ID that you want to invite. Replace the value of --member-id with the value for the member in your account that submits the proposal. [ec2-user@ip-192-0-2-17 ~]$ aws managedblockchain create-proposal \ --actions Invitations=[{Principal=123456789012}] \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-K46ICRRXJRCGRNNS4ES4XUUS5A 8.1: Create an Invitation Proposal 41 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide The command returns the proposal ID, as shown in the following example: { "ProposalId": "p-ZR7KUD2YYNESLNG6RQ33X3FUFE" } Step 8.2: Vote Yes on the Proposal After you create the invitation proposal, use the first member that you created to vote Yes and approve the proposal. You must do this within the duration defined by the network voting policy. 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. From the navigation pane, choose Networks, and then choose the Network for which the proposal was made. 3. Choose Proposals. 4. Under Active, choose the Proposal ID to vote on. 5. Under Vote on proposal, select the member in your account to vote as. If your account has multiple members, each member gets a vote. 6. Choose Yes to vote to approve the proposal. Voting yes is a requirement for the second member to be created in the next step. Choosing No rejects the proposal and an invitation is not created. 7. Choose to Confirm your vote. Step 8.3: Create the New Member To accept an invitation to create a member and join a network, the steps are similar whether you are creating a member in a AMB Access network in a different AWS account or your own AWS account. You first create the member as shown in the following procedures. If you use the AWS CLI, make sure that you have the relevant information, including the Network ID and the Invitation ID that the network sent to your account. When you create a member, you specify the name that identifies your member on the network. You also specify the admin user and password to authenticate to your member certificate authority (CA). 8.2: Vote Yes on the Proposal 42 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide To accept an invitation to create a member and join a network using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. 3. From the navigation pane, |
amazon-managed-blockchain-hyperledger-fabric-dev-017 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 17 | sure that you have the relevant information, including the Network ID and the Invitation ID that the network sent to your account. When you create a member, you specify the name that identifies your member on the network. You also specify the admin user and password to authenticate to your member certificate authority (CA). 8.2: Vote Yes on the Proposal 42 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide To accept an invitation to create a member and join a network using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. 3. From the navigation pane, choose Invitations. Select the invitation that you want to accept from the list, and then choose Accept invitation. To view more information about the network you are invited to join, choose the network Name from the list 4. Under Create member and join network, configure your network member according to the following guidelines: a. Enter a Member name that will be visible to all members and an optional Description. b. Under Hyperledger Fabric certificate authority (CA) configuration specify a username and password to be used as the administrator on the Hyperledger Fabric CA. Remember the user name and password. You need them later any time that you create users and resources that need to authenticate. 5. Choose Create member and join network. To accept an invitation to create a member and join a network using the AWS CLI • Use the create-member command similar to the example below. Replace the value of -- network-id with the Network ID that you are joining and --invitation-id with the Invitation ID sent to your account from the network. aws managedblockchain create-member \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --invitation-id i-XL9MDD6LVWWDNA9FF94Y4TFTE \ --member-configuration 'Name=org2,Description=MyMemberDesc,\ FrameworkConfiguration={Fabric={AdminUsername=MyAdminUsername,\ AdminPassword=Example-Password123}}' The command returns output similar to the following: { "MemberId": "m-J46DNSFRTVCCLONS9DT5TTLS2A" } 8.3: Create the New Member 43 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Additional Steps to Configure a Member After you create the member, perform the following steps to configure the member. As you perform the steps, replace values with those specific to your member configuration, including the Member ID returned by the previous command. The Network ID and OrderingServiceEndpoint are the same for all members. • Step 2: Create and Configure the Interface VPC Endpoint This step is only required if you are creating the second member in a different AWS account. • Step 3: Create a Peer Node in Your Membership • Step 4: Create an Amazon EC2 Instance and Set Up the Hyperledger Fabric Client If you are creating an additional member in the same AWS account, and you already have a Hyperledger Fabric client, you can skip most of these steps. However, you should verify connectivity to the Hyperledger Fabric CA as described in Step 4.2: Set Up the Hyperledger Fabric CA Client, using the new CA endpoint for the new member. • Step 5: Enroll an Administrative User Step 8.4: Share Artifacts and Information with the Network Creator Before a shared channel can be created, the following artifacts and information need to be shared with org1 by org2: • org1 needs the org2 administrative certificate—This certificate is saved the /home/ec2-user/ admin-msp/admincerts directory on org2's Hyperledger Fabric client after Step 5: Enroll an Administrative User. This is referenced in the following steps as Org2AdminCerts • org1 needs the org2 root CA—This certificate is saved to org2's /home/ec2-user/admin- msp/cacerts directory on org2's Hyperledger Fabric client after the same step as previous. This is referenced in the following steps as Org2CACerts • org1 needs the Endpoint of the peer node that will join the channel—This Endpoint value is output by the get-node command after Step 3: Create a Peer Node in Your Membership is complete. 8.4: Share Artifacts 44 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Step 8.5: The Channel Creator (org1) Creates Artifacts for org2's MSP In the following example, the channel creator is org1. The CA administrator for org1 copies the certificates from the step above to a location on the Hyperledger Fabric client computer. The Membership Service Provider (MSP) uses the certificates to authenticate the member. On the channel creator's Hyperledger Fabric client, use the following commands to create directories to store the certificates, and then copy the certificates from the previous step to the new directories: mkdir /home/ec2-user/org2-msp mkdir /home/ec2-user/org2-msp/admincerts mkdir /home/ec2-user/org2-msp/cacerts cp Org2AdminCerts /home/ec2-user/org2-msp/admincerts cp Org2CACerts /home/ec2-user/org2-msp/cacerts Org1 needs org2's member ID. You can get this by running the list-members command on org1's Hyperledger Fabric client as shown in the following example: aws managedblockchain list-members \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU The channel creator (org1) should verify that the required artifacts for channel creation are saved on the Hyperledger Fabric client as shown in the following list: • Org1 MSP artifacts: • /home/ec2-user/admin-msp/signcerts/certname.pem • /home/ec2-user/admin-msp/admincerts/certname.pem • /home/ec2-user/admin-msp/cacerts/certname.pem • /home/ec2-user/admin-msp/keystore/keyname_sk • Org2 MSP artifacts |
amazon-managed-blockchain-hyperledger-fabric-dev-018 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 18 | the certificates, and then copy the certificates from the previous step to the new directories: mkdir /home/ec2-user/org2-msp mkdir /home/ec2-user/org2-msp/admincerts mkdir /home/ec2-user/org2-msp/cacerts cp Org2AdminCerts /home/ec2-user/org2-msp/admincerts cp Org2CACerts /home/ec2-user/org2-msp/cacerts Org1 needs org2's member ID. You can get this by running the list-members command on org1's Hyperledger Fabric client as shown in the following example: aws managedblockchain list-members \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU The channel creator (org1) should verify that the required artifacts for channel creation are saved on the Hyperledger Fabric client as shown in the following list: • Org1 MSP artifacts: • /home/ec2-user/admin-msp/signcerts/certname.pem • /home/ec2-user/admin-msp/admincerts/certname.pem • /home/ec2-user/admin-msp/cacerts/certname.pem • /home/ec2-user/admin-msp/keystore/keyname_sk • Org2 MSP artifacts • /home/ec2-user/org2-msp/admincerts/certname.pem • /home/ec2-user/org2-msp/cacerts/certname.pem • The TLS CA cert used for the Region: • /home/ec2-user/managedblockchain-tls-chain.pem 8.5: Create Artifacts for the MSP 45 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Addresses of all peer nodes to join the channel for both org1 and org2. • The respective member IDs of org1 and org2. • A configtx.yaml file, which you create in the following step, saved to the /home/ec2-user directory on the channel creator's Hyperledger Fabric client. Note If you created this configtx file earlier, delete the old file, rename it, or replace it. Step 8.6: Create configtx for the Multi-Member Channel The configtx.yaml file contains details of the channel configuration. For more information, see Channel Configuration (configtx) in the Hyperledger Fabric documentation. The channel creator creates this file on the Hyperledger File client. If you compare this file to the file created in Step 6.1: Create configtx for Hyperledger Fabric Channel Creation, you see that this configtx.yaml specifies two members in the channel. Use a text editor to create a file with the following contents and save it as configtx.yaml on your Hyperledger File client. • Replace Org1MemberID with the MemberID of the first member that you created when you created the network. For example, m-K46ICRRXJRCGRNNS4ES4XUUS5A. • For &Org1, the MSPDir is set to the same directory location, /opt/home/admin-msp, that you established using the CORE_PEER_MSPCONFIGPATH environment variable in the Docker container for the Hyperledger Fabric CLI in step 4.4 above. • Replace Org2MemberID with the MemberID of the second member that you created in step 8.3. For example, m-J46DNSFRTVCCLONS9DT5TTLS2A. • For &Org2, the MSPDir is set to the same directory location, /opt/home/org2-msp, that you created and copied artifacts to in step 8.5. Important This file is sensitive. Artifacts from pasting can cause the file to fail with marshalling errors. We recommend using emacs to edit it. You can also use VI, but before using VI, enter 8.6: Create configtx 46 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide :set paste, press i to enter insert mode, paste the contents, press escape, and then enter :set nopaste before saving. ################################################################################ # # ORGANIZATIONS # # This section defines the organizational identities that can be referenced # in the configuration profiles. # ################################################################################ Organizations: # Org1 defines an MSP using the sampleconfig. It should never be used # in production but may be used as a template for other definitions. - &Org1 # Name is the key by which this org will be referenced in channel # configuration transactions. # Name can include alphanumeric characters as well as dots and dashes. Name: Org1MemberID # ID is the key by which this org's MSP definition will be referenced. # ID can include alphanumeric characters as well as dots and dashes. ID: Org1MemberID # SkipAsForeign can be set to true for org definitions which are to be # inherited from the orderer system channel during channel creation. This # is especially useful when an admin of a single org without access to the # MSP directories of the other orgs wishes to create a channel. Note # this property must always be set to false for orgs included in block # creation. SkipAsForeign: false Policies: &Org1Policies Readers: Type: Signature Rule: "OR('Org1.member', 'Org2.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.peer', 'Org1.client')" Writers: Type: Signature Rule: "OR('Org1.member', 'Org2.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.client')" 8.6: Create configtx 47 Amazon Managed Blockchain (AMB) Admins: Type: Signature Rule: "OR('Org1.admin')" Hyperledger Fabric Developer Guide # MSPDir is the filesystem path which contains the MSP configuration. MSPDir: /opt/home/admin-msp # AnchorPeers defines the location of peers which can be used for # cross-org gossip communication. Note, this value is only encoded in # the genesis block in the Application section context. AnchorPeers: - Host: 127.0.0.1 Port: 7051 - &Org2 Name: Org2MemberID ID: Org2MemberID SkipAsForeign: false Policies: &Org2Policies Readers: Type: Signature Rule: "OR('Org2.member', 'Org1.member')" # If your MSP is configured with the new NodeOUs, you might # want to use |
amazon-managed-blockchain-hyperledger-fabric-dev-019 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 19 | 8.6: Create configtx 47 Amazon Managed Blockchain (AMB) Admins: Type: Signature Rule: "OR('Org1.admin')" Hyperledger Fabric Developer Guide # MSPDir is the filesystem path which contains the MSP configuration. MSPDir: /opt/home/admin-msp # AnchorPeers defines the location of peers which can be used for # cross-org gossip communication. Note, this value is only encoded in # the genesis block in the Application section context. AnchorPeers: - Host: 127.0.0.1 Port: 7051 - &Org2 Name: Org2MemberID ID: Org2MemberID SkipAsForeign: false Policies: &Org2Policies Readers: Type: Signature Rule: "OR('Org2.member', 'Org1.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.peer', 'Org1.client')" Writers: Type: Signature Rule: "OR('Org2.member', 'Org1.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.client')" Admins: Type: Signature Rule: "OR('Org2.admin')" # MSPDir is the filesystem path which contains the MSP configuration. MSPDir: /opt/home/org2-msp # AnchorPeers defines the location of peers which can be used for # cross-org gossip communication. Note, this value is only encoded in # the genesis block in the Application section context. AnchorPeers: - Host: 127.0.0.1 Port: 7052 ################################################################################ # # CAPABILITIES # # This section defines the capabilities of fabric network. This is a new 8.6: Create configtx 48 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # concept as of v1.1.0 and should not be utilized in mixed networks with # v1.0.x peers and orderers. Capabilities define features which must be # present in a fabric binary for that binary to safely participate in the # fabric network. For instance, if a new MSP type is added, newer binaries # might recognize and validate the signatures from this type, while older # binaries without this support would be unable to validate those # transactions. This could lead to different versions of the fabric binaries # having different world states. Instead, defining a capability for a channel # informs those binaries without this capability that they must cease # processing transactions until they have been upgraded. For v1.0.x if any # capabilities are defined (including a map with all capabilities turned off) # then the v1.0.x peer will deliberately crash. # ################################################################################ Capabilities: # Channel capabilities apply to both the orderers and the peers and must be # supported by both. # Set the value of the capability to true to require it. # Note that setting a later Channel version capability to true will also # implicitly set prior Channel version capabilities to true. There is no need # to set each version capability to true (prior version capabilities remain # in this sample only to provide the list of valid values). Channel: &ChannelCapabilities # V2.0 for Channel is a catchall flag for behavior which has been # determined to be desired for all orderers and peers running at the v2.0.0 # level, but which would be incompatible with orderers and peers from # prior releases. # Prior to enabling V2.0 channel capabilities, ensure that all # orderers and peers on a channel are at v2.0.0 or later. V2_0: true # Orderer capabilities apply only to the orderers, and may be safely # used with prior release peers. # Set the value of the capability to true to require it. Orderer: &OrdererCapabilities # V1.1 for Orderer is a catchall flag for behavior which has been # determined to be desired for all orderers running at the v1.1.x # level, but which would be incompatible with orderers from prior releases. # Prior to enabling V2.0 orderer capabilities, ensure that all # orderers on a channel are at v2.0.0 or later. V2_0: true # Application capabilities apply only to the peer network, and may be safely # used with prior release orderers. # Set the value of the capability to true to require it. # Note that setting a later Application version capability to true will also 8.6: Create configtx 49 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # implicitly set prior Application version capabilities to true. There is no need # to set each version capability to true (prior version capabilities remain # in this sample only to provide the list of valid values). Application: &ApplicationCapabilities # V2.0 for Application enables the new non-backwards compatible # features and fixes of fabric v2.0. # Prior to enabling V2.0 orderer capabilities, ensure that all # orderers on a channel are at v2.0.0 or later. V2_0: true ################################################################################ # # CHANNEL # # This section defines the values to encode into a config transaction or # genesis block for channel related parameters. # ################################################################################ Channel: &ChannelDefaults # Policies defines the set of policies at this level of the config tree # For Channel policies, their canonical path is |
amazon-managed-blockchain-hyperledger-fabric-dev-020 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 20 | sample only to provide the list of valid values). Application: &ApplicationCapabilities # V2.0 for Application enables the new non-backwards compatible # features and fixes of fabric v2.0. # Prior to enabling V2.0 orderer capabilities, ensure that all # orderers on a channel are at v2.0.0 or later. V2_0: true ################################################################################ # # CHANNEL # # This section defines the values to encode into a config transaction or # genesis block for channel related parameters. # ################################################################################ Channel: &ChannelDefaults # Policies defines the set of policies at this level of the config tree # For Channel policies, their canonical path is # /Channel/<PolicyName> Policies: # Who may invoke the 'Deliver' API Readers: Type: ImplicitMeta Rule: "ANY Readers" # Who may invoke the 'Broadcast' API Writers: Type: ImplicitMeta Rule: "ANY Writers" # By default, who may modify elements at this config level Admins: Type: ImplicitMeta Rule: "MAJORITY Admins" # Capabilities describes the channel level capabilities, see the # dedicated Capabilities section elsewhere in this file for a full # description Capabilities: <<: *ChannelCapabilities ################################################################################ # # APPLICATION # # This section defines the values to encode into a config transaction or 8.6: Create configtx 50 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # genesis block for application-related parameters. # ################################################################################ Application: &ApplicationDefaults # Organizations is the list of orgs which are defined as participants on # the application side of the network Organizations: # Policies defines the set of policies at this level of the config tree # For Application policies, their canonical path is # /Channel/Application/<PolicyName> Policies: &ApplicationDefaultPolicies LifecycleEndorsement: Type: ImplicitMeta Rule: "ANY Readers" Endorsement: Type: ImplicitMeta Rule: "ANY Readers" Readers: Type: ImplicitMeta Rule: "ANY Readers" Writers: Type: ImplicitMeta Rule: "ANY Writers" Admins: Type: ImplicitMeta Rule: "MAJORITY Admins" Capabilities: <<: *ApplicationCapabilities ################################################################################ # # PROFILES # # Different configuration profiles may be encoded here to be specified as # parameters to the configtxgen tool. The profiles which specify consortiums # are to be used for generating the orderer genesis block. With the correct # consortium members defined in the orderer genesis block, channel creation # requests may be generated with only the org member names and a consortium # name. # ################################################################################ Profiles: TwoOrgChannel: <<: *ChannelDefaults 8.6: Create configtx 51 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Consortium: AWSSystemConsortium Application: <<: *ApplicationDefaults Organizations: - *Org1 - *Org2 Run the following command to generate the configtx peer block: docker exec cli configtxgen \ -outputCreateChannelTx /opt/home/ourchannel.pb \ -profile TwoOrgChannel -channelID ourchannel \ --configPath /opt/home/ Step 8.7: Create the Channel The channel creator (org1) uses the following command on their Hyperledger Fabric client to submit the channel to the orderer, which creates the channel ourchannel. The command example assumes that Docker environment variables have been configured as described in Step 4.4: Configure and Run Docker Compose to Start the Hyperledger Fabric CLI and that the $ORDERER environment variable has been set on the client. docker exec cli peer channel create -c ourchannel \ -f /opt/home/ourchannel.pb -o $ORDERER \ --cafile /opt/home/managedblockchain-tls-chain.pem --tls Step 8.8: Get Channel Genesis Block Both org1 and org2 need to run the following command on their respective Hyperledger Fabric clients to get the channel's genesis (oldest) block. For more information about the peer channel command, see peer channel in Hyperledger Fabric documentation. docker exec cli peer channel fetch oldest /opt/home/ourchannel.block \ -c ourchannel -o $ORDERER \ --cafile /opt/home/managedblockchain-tls-chain.pem --tls 8.7 Create the Channel 52 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Step 8.9: Join Peer Nodes to the Channel Both org1 and org2 need to run the following command on their respective Hyperledger Fabric clients to join their peer nodes to the channel. For more information, see the peer channel join command example in peer channel section of in the Hyperledger Fabric documentation. docker exec cli peer channel join -b /opt/home/ourchannel.block \ -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls Optionally, after you join a peer to a channel, you can set up the peer node as an anchor peer. Anchor peers support the gossip protocol, which is required for some features of Hyperledger Fabric, such as private data collections and service discovery. For more information, see Add an Anchor Peer to a Channel. Step 8.10: Install Chaincode Both org1 and org2 run the following commands on their respective Hyperledger Fabric clients to install example chaincode on their respective peer nodes: 1. Install the example chaincode package on the peer node. docker exec cli peer lifecycle chaincode install abstore.tar.gz 2. Verify that the chaincode package is installed on the peer node. docker exec cli peer lifecycle chaincode queryinstalled The command returns the following if the package is installed successfully. Installed chaincodes on peer: Package ID: MyPackageID, Label: abstore_1 3. Approve the chaincode definition for the organization. Replace MyPackageID with the Package ID value returned in the previous step. export CC_PACKAGE_ID=MyPackageID docker |
amazon-managed-blockchain-hyperledger-fabric-dev-021 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 21 | org2 run the following commands on their respective Hyperledger Fabric clients to install example chaincode on their respective peer nodes: 1. Install the example chaincode package on the peer node. docker exec cli peer lifecycle chaincode install abstore.tar.gz 2. Verify that the chaincode package is installed on the peer node. docker exec cli peer lifecycle chaincode queryinstalled The command returns the following if the package is installed successfully. Installed chaincodes on peer: Package ID: MyPackageID, Label: abstore_1 3. Approve the chaincode definition for the organization. Replace MyPackageID with the Package ID value returned in the previous step. export CC_PACKAGE_ID=MyPackageID docker exec cli peer lifecycle chaincode approveformyorg \ --orderer $ORDERER --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ 8.9: Join Peer Nodes to the Channel 53 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide --channelID ourchannel --name myjointcc --version v0 --sequence 1 --package-id $CC_PACKAGE_ID 4. Check the commit readiness of the chaincode definition. docker exec cli peer lifecycle chaincode checkcommitreadiness \ --orderer $ORDERER --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ --channelID ourchannel --name myjointcc --version v0 --sequence 1 The command returns true if the chaincode is ready to be committed. 5. Commit the chaincode definition on the channel. docker exec cli peer lifecycle chaincode commit \ --orderer $ORDERER --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ --channelID ourchannel --name myjointcc --version v0 --sequence 1 Step 8.11: Query Chaincode Channel members can run the following command to query the chaincode: docker exec cli peer chaincode query -C ourchannel \ -n myjointcc -c '{"Args":["query","a"]}' The previous command returns the value of a, which you instantiated to a value of 100. You may need to wait a brief moment for the instantiation from the previous step to complete before you run the following command to query a value: Step 8.12: Invoke Chaincode With the channel created and configured with both members, and the chaincode instantiated with values and an endorsement policy, channel members can invoke chaincode. This example command is similar to the example in Step 7.11: Invoke the Chaincode. However, the command uses the --peerAddresses option to specify the endpoints of peer nodes that belong to members in the endorsement policy. The example specifies Org2PeerNodeEndpoint in addition to Org1PeerEndpoint. docker exec cli peer chaincode invoke \ 8.11: Query Chaincode 54 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide -C ourchannel -n myjointcc -c '{"Args":["invoke","a","b","10"]}' \ --peerAddresses Org1PeerEndpoint \ --tlsRootCertFiles /opt/home/managedblockchain-tls-chain.pem \ --peerAddresses Org2PeerNodeEndpoint \ --tlsRootCertFiles /opt/home/managedblockchain-tls-chain.pem \ -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls When we query again using the following command: docker exec cli peer chaincode query -C ourchannel \ -n myjointcc -c '{"Args":["query","a"]}' The command should return the value of a as the new value 90. 8.12: Invoke Chaincode 55 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Create a Hyperledger Fabric Blockchain Network on Amazon Managed Blockchain (AMB) When a user in an AWS account creates a Hyperledger Fabric network on Amazon Managed Blockchain (AMB), they also create the first member in the network. This first member has no peer nodes associated with it until you create them. After you create the network and the first member, you can use that member to create an invitation proposal for other members in the same AWS account or in other AWS accounts. Any member can create an invitation proposal. When you create the network and the first member in your AWS account, the network exists. However, transactions cannot be conducted and the ledger does not exist because there are no peer nodes. Do the following tasks to make your network functional: • Create an interface VPC endpoint based on the network's VPC service name so that you can privately connect to resources. For more information, see Create an Interface VPC Endpoint for Amazon Managed Blockchain (AMB) Hyperledger Fabric. • Create at least one peer node in your first membership to interact with the network and to create and endorse transactions. For more information, see Work with Hyperledger Fabric Peer Nodes on AMB Access. • Create an invitation proposal for other AWS accounts to be members of the network, or invite an additional member in your account to simulate a multi-AWS account network. Vote Yes on your own proposal to approve it and create the invitation. For more information about inviting members, see Create an Invitation Proposal. Create a Hyperledger Fabric Network You can create a Hyperledger Fabric network using the AWS Management Console, the AWS CLI, or the AMB Access SDK CreateNetwork action. To create a Hyperledger Fabric network using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Create private network. 3. Under Blockchain frameworks: Create a Hyperledger Fabric Network 56 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide a. b. Select the blockchain framework to use. This tutorial is based on Hyperledger Fabric version 2.2. Select the Network edition to use. The network edition determines attributes of the |
amazon-managed-blockchain-hyperledger-fabric-dev-022 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 22 | Proposal. Create a Hyperledger Fabric Network You can create a Hyperledger Fabric network using the AWS Management Console, the AWS CLI, or the AMB Access SDK CreateNetwork action. To create a Hyperledger Fabric network using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Create private network. 3. Under Blockchain frameworks: Create a Hyperledger Fabric Network 56 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide a. b. Select the blockchain framework to use. This tutorial is based on Hyperledger Fabric version 2.2. Select the Network edition to use. The network edition determines attributes of the network, such as the maximum number of members, nodes per member, and transaction throughput. Different editions have different rates associated with the membership. For more information, see Amazon Managed Blockchain (AMB) Pricing. 4. Enter a Network name and description. 5. Under Voting Policy, choose the following: a. b. Enter the Approval threshold percentage along with the comparator, either Greater than or Greater than or equal to. For a proposal to pass, the Yes votes cast must meet this threshold before the vote duration expires. Enter the Proposal duration in hours. If enough votes are not cast within this duration to either approve or reject a proposal, the proposal status is EXPIRED, no further votes on this proposal are allowed, and the proposal does not pass. 6. Choose Next, and then, under Create member, do the following to define the first member for the network, which you own: a. Enter a Member name that will be visible to all members and an optional Description. b. Under Hyperledger Fabric certificate authority (CA) configuration specify a username and password to be used as the administrator on the Hyperledger Fabric CA. Remember the user name and password. You need them later any time that you create users and resources that need to authenticate. c. Choose Next. 7. Review Network options and Member options, and then choose Create network and member. The Networks list shows the name and Network ID of the network you created, with a Status of Creating. It takes around 30 minutes for AMB Access to create your network, after which the Status is Available. To create a Hyperledger Fabric network using the AWS CLI Use the create-network command as shown in the following example. Consider the following: Create a Hyperledger Fabric Network 57 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • The example shows HYPERLEDGER_FABRIC as the Framework and 2.2 as the FrameworkVersion. The FrameworkConfiguration properties for --network- configuration and --member-configuration options might be different for other frameworks and versions. • The AdminPassword must be at least 8 characters long and no more than 32 characters. It must contain at least one uppercase letter, one lowercase letter, and one digit. It cannot have a single quote(‘), double quote(“), forward slash(/), backward slash(\), @, percent sign (%), or a space. • The member name must not contain any special characters. • Remember the user name and password. You need them later any time you create users and resources that need to authenticate. [ec2-user@ip-192-0-2-17 ~]$ aws managedblockchain create-network \ --cli-input-json '{\"Name\":\"OurBlockchainNet\", \"Description\": \"OurBlockchainNetDesc\", \"Framework\":\"HYPERLEDGER_FABRIC\",\"FrameworkVersion \": \"2.2\", \"FrameworkConfiguration\": {\"Fabric\": {\"Edition\": \"STARTER \"}}, \"VotingPolicy\": {\"ApprovalThresholdPolicy\": {\"ThresholdPercentage\": 50, \"ProposalDurationInHours\": 24, \"ThresholdComparator\": \"GREATER_THAN \"}}, “MemberConfiguration”: {\"Name\":\"org1\", \"Description\":\"Org1 first member of network\", \"FrameworkConfiguration\":{\"Fabric\":\n{\"AdminUsername\": \"MyAdminUser\",\"AdminPassword\":\"Password123\"}}, \"LogPublishingConfiguration\": {\"Fabric\":{\"CaLogs\":{\"Cloudwatch\": {\"Enabled\": true}}}}}}' The command returns the Network ID and the Member ID, as shown in the following example: { "NetworkId": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "MemberId": "m-K46ICRRXJRCGRNNS4ES4XUUS5A" } Create a Hyperledger Fabric Network 58 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Delete a Hyperledger Fabric Network on Amazon Managed Blockchain (AMB) A Hyperledger Fabric network on Amazon Managed Blockchain (AMB) remains active as long as there are members. A network is deleted only when the last member deletes itself from the network. No member or AWS account, even the creator's AWS account, can delete the network until they are the last member and delete themselves. When you delete the last member, all resources for that member and the blockchain network are deleted. For more information, see Delete a Member in Your AWS Account. 59 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Invite or Remove Hyperledger Fabric Network Members on Amazon Managed Blockchain (AMB) To invite and remove other Hyperledger Fabric network members, any member can create a proposal that is submitted for a vote to all network members. If a proposal is approved within the duration and with the percentage of Yes votes specified in the voting policy for the network, the appropriate action is carried out. A member can only join the network through an approved invitation proposal. The exception is the first member, which is created along with the network. The first member then submits a proposal and is the sole voter on the proposal to invite the second member. Note |
amazon-managed-blockchain-hyperledger-fabric-dev-023 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 23 | To invite and remove other Hyperledger Fabric network members, any member can create a proposal that is submitted for a vote to all network members. If a proposal is approved within the duration and with the percentage of Yes votes specified in the voting policy for the network, the appropriate action is carried out. A member can only join the network through an approved invitation proposal. The exception is the first member, which is created along with the network. The first member then submits a proposal and is the sole voter on the proposal to invite the second member. Note Each member that is created accrues charges according to the membership rate for the network. For more information, see Amazon Managed Blockchain (AMB) Pricing. An AWS account can delete members from the network that they own directly. A proposal is not required. To delete a member in a different AWS account, a proposal to remove the member is required. Information about all proposals, including the member who created the proposal, the current vote count, and more is available to all network members. This topic provides basic information for creating proposals to invite or remove members, and to delete a member that your AWS account owns. For more detailed information about proposals, including how to vote on a proposal, see Work with Proposals for a Hyperledger Fabric Network on Amazon Managed Blockchain (AMB). Create a Proposal to Invite an AWS Account to the Network You can use the AWS Management Console, the AWS CLI, or the AMB Access API to create an invitation proposal. When a proposal to invite a member is approved, an invitation is sent to the specified AWS accounts. An administrator with the appropriate permissions in that account can then choose to either create a member and join the network or reject the invitation. Create an Invitation Proposal 60 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide To create an invitation proposal using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. From the navigation pane, choose Networks, and then choose the network to which you want to invite an AWS account. 3. Choose Proposals and then choose Propose invitation. 4. For Submit proposal as, choose the member in your account that submits the proposal. Note The member who submits the proposal must also vote on it. A Yes vote is not automatically assumed. 5. 6. Enter an optional Description . The description appears to other members. It's a good way to communicate key points or a reminder about the proposal before they vote. For each AWS account that you want to invite, enter the account number in the space provided. Choose Add to enter additional accounts. 7. Choose Create. To create an invitation proposal using the AWS CLI • Type a command similar to the following. Replace the value of Principal with the AWS account ID that you want to invite. Replace the value of --member-id with the value for the member in your account that submits the proposal. [ec2-user@ip-192-0-2-17 ~]$ aws managedblockchain create-proposal \ --actions Invitations=[{Principal=123456789012}] \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-K46ICRRXJRCGRNNS4ES4XUUS5A The command returns the proposal ID, as shown in the following example: { "ProposalId": "p-ZR7KUD2YYNESLNG6RQ33X3FUFE" } Create an Invitation Proposal 61 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Create a Proposal to Remove a Member From the Network You can use the AWS Management Console, the AWS CLI, or the AMB Access API to create a proposal to remove a member owned by another AWS account. To create a proposal to remove a member using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. From the navigation pane, choose Networks, and then choose the network. 3. Choose Proposals and then choose Propose removal. 4. For Submit proposal as, choose the member in your account that submits the proposal. Note The member who submits the proposal must also vote on it. A Yes vote is not automatically assumed. 5. 6. Enter an optional Description . The description appears to other members. It's a good way to communicate key points or a reminder about the proposal before they vote. For each member that you want to remove, enter the member ID in the space provided. Choose Add to enter additional members. To create a removal proposal using the AWS CLI • Type a command similar to the following. Replace the value of Principal with the AWS account ID that you want to invite. Replace the value of --member-id with the value for the member in your account that submits the proposal. [ec2-user@ip-192-0-2-17 ~]$ aws managedblockchain create-proposal \ --actions Removals=[{MemberID=m-K46ICRRXJRCGRNNS4ES4XUUS5A}] \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-J46DNSFRTVCCLONS9DT5TTLS2A The command returns the proposal ID, as shown in the following example: { "ProposalId": "p-ZR7KUD2YYNESLNG6RQ33X3FUFE" Create a Removal Proposal 62 Amazon Managed |
amazon-managed-blockchain-hyperledger-fabric-dev-024 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 24 | enter the member ID in the space provided. Choose Add to enter additional members. To create a removal proposal using the AWS CLI • Type a command similar to the following. Replace the value of Principal with the AWS account ID that you want to invite. Replace the value of --member-id with the value for the member in your account that submits the proposal. [ec2-user@ip-192-0-2-17 ~]$ aws managedblockchain create-proposal \ --actions Removals=[{MemberID=m-K46ICRRXJRCGRNNS4ES4XUUS5A}] \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-J46DNSFRTVCCLONS9DT5TTLS2A The command returns the proposal ID, as shown in the following example: { "ProposalId": "p-ZR7KUD2YYNESLNG6RQ33X3FUFE" Create a Removal Proposal 62 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide } Delete a Member in Your AWS Account You can use the AWS Management Console, the AWS CLI, or the AMB Access API to directly remove members that your AWS account owns from a network. Warning Removing a member in your account deletes all associated resources, such as peer nodes. For your AWS account to rejoin the network, an existing member must create a proposal to invite your AWS account, and the proposal must be approved. To delete a member in your account using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks, choose the network Name, and then choose Members. 3. Under Members owned by you, select a member and then choose Delete member. 4. Choose Delete when prompted to confirm. To delete a member in your account using the AWS CLI • Use the delete-member command as shown in the following example. Replace the values of --network-id and --member-id as appropriate. aws managedblockchain delete-member --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU -- member-id m-J46DNSFRTVCCLONS9DT5TTLS2A Delete a Member in Your AWS Account 63 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Accept an Invitation to Create a Member and Join a Hyperledger Fabric Network on Amazon Managed Blockchain (AMB) In Amazon Managed Blockchain (AMB), a member is a distinct identity within the Hyperledger Fabric network associated with an AWS account. An AWS account can have multiple members on the network. Every member in a network must be invited to participate through a proposal made by an existing member and approved according to the network's voting policy. The exception is the first member, which is created along with the network. For more information, see Work with Proposals for a Hyperledger Fabric Network on Amazon Managed Blockchain (AMB). After the invitation is approved, the invited AWS account can create a member and join the network using the invitation ID. Each member pays an hourly rate, billed per second, for their network membership, peer nodes, and peer node storage. Charges also apply to the amount of data written to the network. Charges may vary depending on the network edition selected when the network was created. For more information, see Amazon Managed Blockchain (AMB) Pricing. The resources associated with a member's account depend on the specific blockchain framework and application requirements, but each member must have the following resources: • An interface VPC endpoint in the account–AMB Access is a PrivateLink-powered service, so you must have an interface VPC endpoint in your account to communicate with the service endpoint that the AMB Access network makes available. For more information, see Create an Interface VPC Endpoint for Amazon Managed Blockchain (AMB) Hyperledger Fabric and Key Concepts: Amazon Managed Blockchain (AMB) Networks, Members, and Peer Nodes. • One or more peer nodes–Each member must have at least one peer node to actively participate in the blockchain network. When you create a member it has no peer nodes by default. You create peer nodes after you create the member. Peer nodes run on AMB Access instances. Custom Amazon EC2 instances or on-premises instances cannot participate as peer nodes on a Hyperledger Fabric network on AMB Access. For more information, see Work with Hyperledger Fabric Peer Nodes on AMB Access. Topics • Work with Invitations 64 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Create a Member and Join a Network Work with Invitations If you are invited to join a Hyperledger Fabric network on Amazon Managed Blockchain (AMB), you can accept the invitation by creating a member using the invitation ID. You can also reject the invitation. After you reject an invitation, the invitation ID is no longer valid. A new invitation proposal must be approved, and a new invitation ID is required to create a member. If don't accept or reject an invitation before it expires, the invitation lapses. As with a rejected invitation, a new invitation ID is required. You can see all pending, accepted, and rejected invitations for your AWS account in the AWS Management Console. Alternatively, you can use the AWS CLI or the AMB Access SDK ListInvitations action. You can set up Amazon CloudWatch Events along with Amazon Simple Notification Service so that |
amazon-managed-blockchain-hyperledger-fabric-dev-025 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 25 | you reject an invitation, the invitation ID is no longer valid. A new invitation proposal must be approved, and a new invitation ID is required to create a member. If don't accept or reject an invitation before it expires, the invitation lapses. As with a rejected invitation, a new invitation ID is required. You can see all pending, accepted, and rejected invitations for your AWS account in the AWS Management Console. Alternatively, you can use the AWS CLI or the AMB Access SDK ListInvitations action. You can set up Amazon CloudWatch Events along with Amazon Simple Notification Service so that you receive an alert when there is an invitation for your account. For more information, see Automating AMB Access Proposal Notifications with CloudWatch Events. To list blockchain network member invitations for your AWS account using the console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Invitations, and then do one of the following: To... Do this... View details about the network, such as the network ID, the description, endpoints, voting policy details, and current members. Use the invitation to create a member and join the network. Reject the invitation. Select the invitation from the list and choose View details. Select the invitation from the list and choose Accept Invitation. For next steps, see Create a Member and Join a Network Select the invitation from the list and choose Reject Invitation. Work with Invitations 65 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide To list blockchain network member invitations for your AWS account using the AWS CLI • Use the following command: aws managedblockchain list-invitations The command returns a list of invitations, along with detail for each invitation, as shown in the following example for an invitation in the PENDING status: { "Invitations": [ { "CreationDate": 2019-04-08T23:40:20.628Z, "ExpirationDate": 2019-04-09T23:40:20.628Z, "InvitationId": "i-XL9MDD6LVWWDNA9FF94Y4TFTE", "NetworkSummary": { "CreationDate": 2019-04-03T13:15:22.345Z, "Description": "Test network for supply chain blockchain.", "Framework": "HYPERLEDGER_FABRIC", "FrameworkVersion": "2.2", "Id": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "Name": "Example Corp.", "Status": "AVAILABLE" }, "Status": "PENDING" } ] } You can use the InvitationID with the create-member command to create a member and join the network. For next steps, see Create a Member and Join a Network. Create a Member and Join a Network You can use the AMB Access console, the AWS CLI, or the AMB Access SDK CreateMember action to create a member in a network that your account is invited to. If you created the network, you create the first member when you create the network. All subsequent members must be invited to join by way of a member proposal. Create a Member 66 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide After you create the member, for the member to be functional on the network, your account must have a VPC endpoint associated with the VPC endpoint service name published by the network. For more information, see Create an Interface VPC Endpoint for Amazon Managed Blockchain (AMB) Hyperledger Fabric. You also must create at least one peer node in your membership. For more information, see Work with Hyperledger Fabric Peer Nodes on AMB Access. To accept an invitation to create a member and join a network using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. 3. From the navigation pane, choose Invitations. Select the invitation that you want to accept from the list, and then choose Accept invitation. To view more information about the network you are invited to join, choose the network Name from the list 4. Under Create member and join network, configure your network member according to the following guidelines: a. Enter a Member name that will be visible to all members and an optional Description. b. Under Hyperledger Fabric certificate authority (CA) configuration specify a username and password to be used as the administrator on the Hyperledger Fabric CA. Remember the user name and password. You need them later any time that you create users and resources that need to authenticate. 5. Choose Create member and join network. To accept an invitation to create a member and join a network using the AWS CLI • Use the create-member command similar to the example below. Replace the value of -- network-id with the Network ID that you are joining and --invitation-id with the Invitation ID sent to your account from the network. aws managedblockchain create-member \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --invitation-id i-XL9MDD6LVWWDNA9FF94Y4TFTE \ --member-configuration 'Name=org2,Description=MyMemberDesc,\ FrameworkConfiguration={Fabric={AdminUsername=MyAdminUsername,\ AdminPassword=Example-Password123}}' Create a Member 67 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide The command returns output similar to the following: { "MemberId": "m-J46DNSFRTVCCLONS9DT5TTLS2A" } After you create the member, you can use the get-member command to return important details about the member configuration. Create a Member 68 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Create an Interface VPC Endpoint for Amazon Managed Blockchain (AMB) Hyperledger Fabric Each member of a |
amazon-managed-blockchain-hyperledger-fabric-dev-026 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 26 | are joining and --invitation-id with the Invitation ID sent to your account from the network. aws managedblockchain create-member \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --invitation-id i-XL9MDD6LVWWDNA9FF94Y4TFTE \ --member-configuration 'Name=org2,Description=MyMemberDesc,\ FrameworkConfiguration={Fabric={AdminUsername=MyAdminUsername,\ AdminPassword=Example-Password123}}' Create a Member 67 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide The command returns output similar to the following: { "MemberId": "m-J46DNSFRTVCCLONS9DT5TTLS2A" } After you create the member, you can use the get-member command to return important details about the member configuration. Create a Member 68 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Create an Interface VPC Endpoint for Amazon Managed Blockchain (AMB) Hyperledger Fabric Each member of a Hyperledger Fabric network on AMB Access needs to privately access resource endpoints from their client applications and tools. Amazon Managed Blockchain (AMB) uses Interface VPC Endpoints (AWS PrivateLink) to accomplish this. AMB Access creates a VPC service name for each network when it is created. Each network is a unique endpoint service with its own VPC service name. Each member then uses the VPC service name to create an interface VPC endpoint in their account. This interface VPC endpoint lets you access resources on the Hyperledger Fabric network on AMB Access through their endpoints. AWS accounts that are not invited to the network don't have access to the VPC service name and cannot set up an interface VPC endpoint for access. The IAM principal (user) identity that you are using must have sufficient IAM permissions to create an interface VPC endpoint in your AWS account. For more information, see Controlling Access - Creating and Managing VPC Endpoints in the Amazon VPC User Guide. Any blockchain framework clients that access resources on the network need access to the interface VPC endpoint. For example, if you use an Amazon EC2 instance as a Hyperledger Fabric client, you can create it in a subnet and security group that are shared with the interface VPC endpoint. Applicable charges for interface VPC endpoints apply. For more information, see AWS PrivateLink Pricing. The interface VPC endpoint that you set up to access a network must be enabled for private DNS names. This requires that you create the endpoint in a VPC that has the enableDnsHostnames and enableDnsSupport options set to true. To create an interface VPC endpoint using the AMB Access console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks, select your network from the list, and then choose View details. 3. Choose Create VPC endpoint. 4. Choose a VPC. 5. For Subnets, choose a subnet from the list, and then choose additional subnets as necessary. 69 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide 6. For Security groups, choose an EC2 security group from the list, and then choose additional security groups as necessary. We recommend that you select the same security group that your framework client EC2 instance is associated with. 7. Choose Create. To create an interface VPC Endpoint for a network 1. Find the VPC endpoint service name of the network. This value is returned by get-network command using the AMB Access CLI, and is available on the network Details page using the AMB Access console (choose Networks, select the network from the list, and then choose View details). 2. Open the Amazon VPC console at https://console.aws.amazon.com/vpc/. 3. Choose Endpoints, Create Endpoint. 4. Choose Find service by name. For Service Name, enter the VPC Endpoint Service Name from step 1. 5. Choose Verify and then choose Create endpoint. 6. Make sure that Enable Private DNS Name is selected. This option is only available if the VPC you selected has Enable DNS hostnames and Enable DNS support set to true for the VPC. This is a requirement for the VPC. 7. We recommend that the EC2 security group that you specify for the VPC endpoint is the same as the EC2 security group for the blockchain client that you create to work with the network. 70 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Work with Hyperledger Fabric Peer Nodes on AMB Access Hyperledger Fabric peer nodes do the work for your member on the network. They keep a local copy of the shared ledger, let you query the ledger, and interact with clients and other peer nodes to perform transactions. A new member has no peer nodes. Create at least one peer node per member. Each peer node runs on a AMB Access instance type. You cannot add a custom Amazon EC2 instance to your member, nor can you connect an on-premises machine. The number of peer nodes and the AMB Access instance type of peer nodes available to each member depends on the network edition specified when the network was created. For more information, see Amazon Managed Blockchain (AMB) Pricing. When you create a peer node, you select the following characteristics: • AMB Access instance type This determines |
amazon-managed-blockchain-hyperledger-fabric-dev-027 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 27 | transactions. A new member has no peer nodes. Create at least one peer node per member. Each peer node runs on a AMB Access instance type. You cannot add a custom Amazon EC2 instance to your member, nor can you connect an on-premises machine. The number of peer nodes and the AMB Access instance type of peer nodes available to each member depends on the network edition specified when the network was created. For more information, see Amazon Managed Blockchain (AMB) Pricing. When you create a peer node, you select the following characteristics: • AMB Access instance type This determines the computational and memory capacity allocated to this node for the blockchain workload. You can choose more CPU and RAM if you anticipate a more demanding workload for each node. For example, your nodes may need to process a higher rate of transactions. Different instance types are subject to different pricing. You can monitor CPU and memory utilization to determine if your AMB Access instance type is appropriate. For more information, see Use Hyperledger Fabric Peer Node Metrics on Amazon Managed Blockchain (AMB) • Availability Zone You can select the Availability Zone to launch the peer node in. The ability to distribute peer nodes in a member across different Availability Zones allows you to design your blockchain application for resiliency. For more information, see Regions and Availability Zones in the Amazon EC2 User Guide. • State DB configuration This determines the type of state database that the peer node uses. LevelDB stores chaincode data as simple key-value pairs. It supports only key, key range, and composite key queries. • Logging configuration 71 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide You can enable peer node logs, chaincode logs, or both for a member. Peer node logs allow you to debug timeout errors associated with proposals and identify rejected proposals. Chaincode logs help you analyze and debug business logic. For more information, see Monitoring AMB Access Hyperledger Fabric Using CloudWatch Logs. Create a Hyperledger Fabric Peer Node on Amazon Managed Blockchain (AMB) You can create a Hyperledger Fabric peer node in a member that is in your AWS account using the AWS Management Console, the AWS CLI, or the AMB Access SDK CreateNode action. To create a peer node using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks, select the network from the list, and then choose View details. 3. Select a Member from the list, and then choose Create peer node. 4. Choose configuration parameters for your peer node according to the guidelines in Work with Hyperledger Fabric Peer Nodes on AMB Access, and then choose Create peer node. To create a peer node using the AWS CLI • Use the create-node command, as shown in the following example. Replace the value of -- network-id, --member-id, and AvailabilityZone as appropriate. [ec2-user@ip-192-0-2-17 ~]$ aws managedblockchain create-node \ --node-configuration '{"InstanceType":"bc.t3.small","AvailabilityZone":"us- east-1a"}' \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-K46ICRRXJRCGRNNS4ES4XUUS5A The command returns output that includes the peer node's NodeID, as shown in the following example: { "NodeId": "nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y" Create a Peer Node 72 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide } View Hyperledger Fabric Peer Node Properties on Amazon Managed Blockchain (AMB) You can view information about each Hyperledger Fabric peer node that belong to your member using the AWS Management Console, the AWS CLI or the AMB Access API GetNode command. Details include basic information like the AMB Access instance type, Availability Zone, and creation date, along with the following important properties: • Status • Creating AMB Access is provisioning and configuring the AMB Access instance for the peer node. • Available The peer node is running and available on the network. • Failed The peer node has an issue that has caused AMB Access to add it to the deny list on the network. This usually indicates that the peer node has reached memory or storage capacity. As a first step, we recommend that you delete the instance and provision an instance with more capacity. • Create Failed The node could not be created with the AMB Access instance type and the Availability Zone specified. We recommend trying another availability zone, a different instance type, or both. • Deleting The node is being deleted. This can happen because the node was deleted by the member, the member was deleted by the AWS account, or the member was deleted through an approved removal proposal. • Deleted The node has been deleted. See the previous item for possible reasons. • Endpoints View Peer Node Properties 73 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Hyperledger Fabric uses endpoints associated with each peer node to identify the peer node on the network for different processes. AMB Access assigns unique peer node endpoints to each peer node on |
amazon-managed-blockchain-hyperledger-fabric-dev-028 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 28 | type, or both. • Deleting The node is being deleted. This can happen because the node was deleted by the member, the member was deleted by the AWS account, or the member was deleted through an approved removal proposal. • Deleted The node has been deleted. See the previous item for possible reasons. • Endpoints View Peer Node Properties 73 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Hyperledger Fabric uses endpoints associated with each peer node to identify the peer node on the network for different processes. AMB Access assigns unique peer node endpoints to each peer node on each network when the peer node is created. The peer node endpoint consists of the applicable port and the domain name of the peer node derived from the network ID, member ID, and peer node ID. For more information, see Identifying AMB Access Resources and Connecting from a Client. Do not assume that the ports for a service are the same among members; different members may use different ports for the same service. Conversely, peer nodes in different networks may use the same ports, but their endpoints are always unique. • Peer endpoint Use this endpoint, including the port, within Hyperledger Fabric to address the peer node when using all services other than peer channel-based event services. • Peer event endpoint Use this endpoint, including the port, within Hyperledger Fabric to address the peer node for peer channel-based event services. You can also view and monitor Metrics related to peer node performance. For more information, see Use Hyperledger Fabric Peer Node Metrics on Amazon Managed Blockchain (AMB). You can check the peer node status using the get-node command, as shown in the following example: aws managedblockchain get-node \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-K46ICRRXJRCGRNNS4ES4XUUS5A \ --node-id nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y The command returns output that includes the peer node's PeerEndpoint and PeerEventEndpoint, as shown in the following example. You need this endpoint and port when communicating with the node using your blockchain framework client or addressing the node within an application. { "Node": { "AvailabilityZone": "us-east-1a", "CreationDate": 2019-04-08T23:40:20.628Z, "FrameworkAttributes": { View Peer Node Properties 74 Amazon Managed Blockchain (AMB) "Fabric": { Hyperledger Fabric Developer Guide "PeerEndpoint": "nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y.m- K46ICRRXJRCGRNNS4ES4XUUS5A.n-MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us- east-1.amazonaws.com:30003", "PeerEventEndpoint": "nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y.m- K46ICRRXJRCGRNNS4ES4XUUS5A.n-MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us- east-1.amazonaws.com:30004" } }, "Id": "nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y", "InstanceType": "bc.t3.small", "LogPublishingConfiguration": { "Fabric": { "ChaincodeLogs": { "Cloudwatch": { "Enabled": true } }, "PeerLogs": { "Cloudwatch": { "Enabled": true } } } }, "StateDB": "CouchDB" "Status": "AVAILABLE" } } Use Hyperledger Fabric Peer Node Metrics on Amazon Managed Blockchain (AMB) You can use peer node metrics to track the activity and health of Hyperledger Fabric peer nodes on Amazon Managed Blockchain (AMB) that belong to your member. You can use the AMB Access console to view the metrics for a peer node. AMB Access also reports metrics to Amazon CloudWatch. You can use CloudWatch to set up dashboards, receive alarms, and view log files for peer node metrics. For more information, see Using Amazon CloudWatch Metrics in the Amazon CloudWatch User Guide. Use Peer Node Metrics 75 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide In addition to using peer node metrics, you optionally can enable CloudWatch Logs for peer nodes and for instances of chaincode running on a peer node to view Peer node logs and Chaincode logs. These logs are useful for troubleshooting and analysis of chaincode activity. For more information, see Monitoring AMB Access Hyperledger Fabric Using CloudWatch Logs. AMB Access collects the following metrics for each peer node in the aws/managedblockchain namespace. Available metrics in AMB Access correspond to Hyperledger Fabric metrics. Metric name Fabric metrics ChaincodeExecuteTimeouts EndorserProposalDuration Description The number of chaincode executions (Init or Invoke) that have timed out. Units: Count For each proposal, the time to complete the proposal. Units: Seconds EndorserProposalValidationFailures The number of proposals that have failed initial validation. Units: Count EndorserProposalsReceived The number of proposals received. Units: Count EndorserSuccessfulProposals The number of successful proposals. Transactions Utilization metrics Units: Count The number of transactions that a peer node receives per minute. Units: Count Use Peer Node Metrics 76 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Metric name CPUUtilization Description The percentage of total CPU capacity used on the peer node's AMB Access instance at any given instant. Units: Percent MemoryUtilization The percentage of total available memory used on the peer node's AMB Access instance at any given instant. Units: Percent Viewing Peer Node Metrics You can use the Amazon Managed Blockchain (AMB) console to view graphs for peer node metrics. Metrics are available on the peer node details page. To view metrics using the AMB Access console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Under Network, choose the Name of the network. 3. Choose Members. Under Members owned by you, choose the Name of the member to which the node belongs. 4. Under Peer |
amazon-managed-blockchain-hyperledger-fabric-dev-029 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 29 | instant. Units: Percent MemoryUtilization The percentage of total available memory used on the peer node's AMB Access instance at any given instant. Units: Percent Viewing Peer Node Metrics You can use the Amazon Managed Blockchain (AMB) console to view graphs for peer node metrics. Metrics are available on the peer node details page. To view metrics using the AMB Access console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Under Network, choose the Name of the network. 3. Choose Members. Under Members owned by you, choose the Name of the member to which the node belongs. 4. Under Peer Nodes, choose the Node ID you want to view. Under Metrics, tabs for Channel Metrics and Utilization Metrics are available. 5. For Channel Metrics, choose the channels you want to view or compare from the list. 6. Choose a chart and then use Statistics, Time Range, and Period to customize the chart. Viewing Peer Node Metrics 77 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Viewing Peer Node Metrics 78 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Work with Proposals for a Hyperledger Fabric Network on Amazon Managed Blockchain (AMB) To make a change to a Hyperledger Fabric network on Amazon Managed Blockchain (AMB) that requires consensus among network members, network members create proposals. For example, a member can create a proposal to invite another AWS account to become a member, to invite multiple accounts, or to remove one or more members in different AWS accounts. A proposal is submitted to all network members to cast a Yes or No vote. If the proposal is approved within the duration and with the percentage of Yes votes specified in the voting policy for the network, the proposed action is carried out. The voting policy is established when the network is created and governs votes on all proposals. It can't be updated after the network is created. For more information, see Create a Hyperledger Fabric Blockchain Network on Amazon Managed Blockchain (AMB). Understanding the Proposal Lifecycle To understand the proposal lifecycle, consider a hypothetical proposal to invite AWS account 123456789012 to join a Hyperledger Fabric network on AMB Access made by a member named Org3. The network currently has six members: Org1, Org2, Org3, and so on. The network was created by Org1, who specified a voting policy with a 50% approval threshold, a greater than comparator, and a proposal duration of 24 hours. The following flow diagrams depict the possible outcomes of a proposal using this example: • Approved with Full Vote • Approved with Partial Vote • Rejected with Full Vote • Rejected with Partial Vote • Expired, Does Not Pass Example – Proposal approved with full member vote For the following proposal, all members cast a vote before the duration expired. The proposal is APPROVED, and an invitation is extended to the AWS account. 79 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Example – Proposal approved with partial member vote For the following proposal, not all members cast a vote before the duration expired. However, enough Yes votes were cast to approve the proposal according to the voting policy. The proposal is APPROVED, and an invitation is extended to the AWS account. Example – Proposal rejected with full member vote For the following proposal, all members cast a vote before the duration expired. Because the comparator in the voting policy is greater than, a three-to-three vote does not pass the threshold for approval. The proposal is REJECTED, and an invitation is not extended to the AWS account. 80 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Example – Proposal rejected with partial member vote For the following proposal, not all members cast a vote before the duration expired. However, enough No votes were cast to reject the proposal according to the voting policy. The proposal is REJECTED, and an invitation is not extended to the AWS account. Example – Proposal expires and is not approved For the following proposal, not all members cast a vote before the duration expired, and neither the number of Yes nor No votes were cast to determine the outcome of the proposal. The proposal is EXPIRED, and an invitation is not extended to the AWS account. 81 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide View Proposals All proposals made on a network are shown on the Proposals page for a network. Both Active proposals and Completed proposals are listed. Active proposals are still open for voting. You can also list proposals from the AWS CLI using the list-proposals command, or using the ListProposals action with the AMB Access API. The Proposals page for a network shows both Active and Completed proposals, listing the Proposal ID, the name of the member that created the proposal, and the Expiration Date (UTC), which is |
amazon-managed-blockchain-hyperledger-fabric-dev-030 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 30 | to the AWS account. 81 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide View Proposals All proposals made on a network are shown on the Proposals page for a network. Both Active proposals and Completed proposals are listed. Active proposals are still open for voting. You can also list proposals from the AWS CLI using the list-proposals command, or using the ListProposals action with the AMB Access API. The Proposals page for a network shows both Active and Completed proposals, listing the Proposal ID, the name of the member that created the proposal, and the Expiration Date (UTC), which is the creation time plus the proposal duration specified in the network's voting policy. You can choose a Proposal ID to vote on active proposals and to see more detail about any proposal, including the actions proposed and a voting summary by member. Proposals have one of the following statuses: • IN_PROGRESS - The proposal is active and open for member voting. • APPROVED - The proposal was approved with sufficient YES votes among members according to the VotingPolicy specified for the Network. The specified proposal actions are carried out. • REJECTED - The proposal was rejected with insufficient YES votes among members according to the VotingPolicy specified for the Network. The specified ProposalActions are not carried out. • EXPIRED - Members did not cast the number of votes required to determine the proposal outcome before the proposal expired. The specified ProposalActions are not carried out. View Proposals 82 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • ACTION_FAILED - One or more of the specified ProposalActions in a proposal that was approved could not be completed because of an error. The ACTION_FAILED status occurs even if only one proposal action fails and other actions are successful. To view proposals for a network using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks, choose a network Name, and then choose Proposals. 3. Choose a Proposal ID from the list to view more detailed information, such as the description, a summary of Actions, and a Voting Summary. 4. Under Voting Summary, expand Votes to see individual member's votes on the proposal to date. To view proposals for a network using the AWS CLI • Enter a command similar to the following example. Replace n- MWY63ZJZU5HGNCMBQER7IN6OIU with the network ID for which you want to list proposals. aws managedblockchain list-proposals --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU The command returns output similar to the following: { "Proposals": [ { "CreationDate": 2019-04-08T23:40:20.628Z, "Description": "Proposal to add Example Corp. member", "ExpirationDate": 2019-04-09T23:40:20.628Z, "ProposalId": "p-ZR7KUD2YYNESLNG6RQ33X3FUFE", "ProposedByMemberId": "m-J46DNSFRTVCCLONS9DT5TTLS2A", "ProposedByMemberName": "org1", "Status": "IN_PROGRESS" } ] } View Proposals 83 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide To view the details of a proposal using the AWS CLI • Enter a command similar to the following. Replace n-MWY63ZJZU5HGNCMBQER7IN6OIU with the network ID and p-ZR7KUD2YYNESLNG6RQ33X3FUFE with the proposal ID to view. aws managedblockchain get-proposal --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU -- proposal-id p-ZR7KUD2YYNESLNG6RQ33X3FUFE The command returns output similar to the following: { "Proposal": { "Actions": { "Invitations": [ { "Principal": "0123456789012" } ], "CreationDate": 2019-04-08T23:40:20.628Z, "Description": "Proposal to invite AWS Acct 0123456789012", "ExpirationDate": 2019-04-08T23:40:20.628Z, "NetworkId": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "NoVoteCount": 1, "OutstandingVoteCount": 3, "ProposalId": "p-ZR7KUD2YYNESLNG6RQ33X3FUFE", "ProposedByMemberId": "m-J46DNSFRTVCCLONS9DT5TTLS2A", "ProposedByMemberName": "org1", "Status": "IN_PROGRESS", "YesVoteCount": 2 } } Vote on a Proposal You can use the AWS Management Console, the AWS CLI vote-on-proposal command, or the VoteOnProposal action of the AMB Access API to vote Yes or No on an active proposal. You cannot change a vote after you make it. Vote on a Proposal 84 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide To vote on a proposal using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks, choose a network Name, and then choose Proposals. 3. From the list of Active proposals, choose a Proposal ID. 4. Under Vote on proposal, choose the member to vote as from the list, and then choose Yes or No. 5. When prompted, choose Confirm. To vote on a proposal using the AWS CLI • Use the vote-on-proposal command as shown in the following example. Replace the values of --network-id, --member-id, and --vote as appropriate. aws managedblockchain vote-on-proposal --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU -- proposal-id p-ZR7KUD2YYNESLNG6RQ33X3FUFE --member-id m-K46ICRRXJRCGRNNS4ES4XUUS5A --vote YES Create an Invitation Proposal You can use the AWS Management Console, the AWS CLI, or the AMB Access API to create an invitation proposal. To create an invitation proposal using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. From the navigation pane, choose Networks, and then choose the network to which you want to invite an AWS account. 3. Choose Proposals and then choose Propose invitation. 4. For Submit proposal as, choose the member in your account that submits the proposal. Note The member who submits the proposal must also vote on |
amazon-managed-blockchain-hyperledger-fabric-dev-031 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 31 | m-K46ICRRXJRCGRNNS4ES4XUUS5A --vote YES Create an Invitation Proposal You can use the AWS Management Console, the AWS CLI, or the AMB Access API to create an invitation proposal. To create an invitation proposal using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. From the navigation pane, choose Networks, and then choose the network to which you want to invite an AWS account. 3. Choose Proposals and then choose Propose invitation. 4. For Submit proposal as, choose the member in your account that submits the proposal. Note The member who submits the proposal must also vote on it. A Yes vote is not automatically assumed. Create an Invitation Proposal 85 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide 5. 6. Enter an optional Description . The description appears to other members. It's a good way to communicate key points or a reminder about the proposal before they vote. For each AWS account that you want to invite, enter the account number in the space provided. Choose Add to enter additional accounts. 7. Choose Create. To create an invitation proposal using the AWS CLI • Type a command similar to the following. Replace the value of Principal with the AWS account ID that you want to invite. Replace the value of --member-id with the value for the member in your account that submits the proposal. [ec2-user@ip-192-0-2-17 ~]$ aws managedblockchain create-proposal \ --actions Invitations=[{Principal=123456789012}] \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-K46ICRRXJRCGRNNS4ES4XUUS5A The command returns the proposal ID, as shown in the following example: { "ProposalId": "p-ZR7KUD2YYNESLNG6RQ33X3FUFE" } Create a Proposal to Remove a Network Member To create a proposal to remove a member using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. From the navigation pane, choose Networks, and then choose the network. 3. Choose Proposals and then choose Propose removal. 4. For Submit proposal as, choose the member in your account that submits the proposal. Create a Removal Proposal 86 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Note The member who submits the proposal must also vote on it. A Yes vote is not automatically assumed. 5. 6. Enter an optional Description . The description appears to other members. It's a good way to communicate key points or a reminder about the proposal before they vote. For each member that you want to remove, enter the member ID in the space provided. Choose Add to enter additional members. To create a removal proposal using the AWS CLI • Type a command similar to the following. Replace the value of Principal with the AWS account ID that you want to invite. Replace the value of --member-id with the value for the member in your account that submits the proposal. [ec2-user@ip-192-0-2-17 ~]$ aws managedblockchain create-proposal \ --actions Removals=[{MemberID=m-K46ICRRXJRCGRNNS4ES4XUUS5A}] \ --network-id n-MWY63ZJZU5HGNCMBQER7IN6OIU \ --member-id m-J46DNSFRTVCCLONS9DT5TTLS2A The command returns the proposal ID, as shown in the following example: { "ProposalId": "p-ZR7KUD2YYNESLNG6RQ33X3FUFE" } Automating AMB Access Proposal Notifications with CloudWatch Events Amazon CloudWatch Events enables you to automate your AWS services and respond automatically to system events. Events from AWS services are delivered to CloudWatch Events in near real time on a best-effort basis. You can write simple rules to indicate which events are of interest to you, and what automated actions to take when an event matches a rule. With AMB Access, you can monitor CloudWatch Events events to respond to proposals, including invitations Automating with CloudWatch Events 87 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide sent to your AWS account to join a network, and notification that proposals are APPROVED or REJECTED. Some examples include notifying an Amazon SNS topic or an AWS SMS queue when an invitation is sent or when a proposal made by a member in your account changes status. For more information, see the Amazon CloudWatch Events User Guide. Example AMB Access Events AWS Account Received an Invitation Event The detail-type of these messages is Managed Blockchain Invitation State Change. { "version": "0", "id": "abcd1234-eeee-4321-a1a2-123456789012", "detail-type": "Managed Blockchain Invitation State Change", "source": "aws.managedblockchain", "account": "123456789012", "time": "2019-04-08T23:40:20.628Z", "region": "us-east-1", "resources": [], "detail": { "invitationId": "i-XL9MDD6LVWWDNA9FF94Y4TFTE", "networkId": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "networkName": "ExampleCorpNetwork", "status": "PENDING", "expirationDate": "2019-04-09T23:40:20.628Z", "message": "You have received invitation i-XL9MDD6LVWWDNA9FF94Y4TFTE for Amazon Managed Blockchain (AMB) Network n-MWY63ZJZU5HGNCMBQER7IN6OIU and it will expire at 2016-12-16 20:42 UTC." } } Proposal State Change Event The detail-type of these messages is Managed Blockchain Proposal State Change. The following example shows an event for a proposal that changed state to APPROVED. { "version": "0", "id": "abcd1234-eeee-4321-a1a2-123456789012", "detail-type": "Managed Blockchain Proposal State Change", Example AMB Access Events 88 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "source": "aws.managedblockchain", "account": "123456789012", "time": "2019-04-08T23:40:20.628Z", "region": "us-east-1", "resources": [], "detail": { "proposalId": "p-ZR7KUD2YYNESLNG6RQ33X3FUFE", "networkId": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "status": "APPROVED", "proposedByMemberId": "m-K46ICRRXJRCGRNNS4ES4XUUS5A", "proposedByMemberName": "NetworkMember1", "expirationDate": "2019-04-09T23:40:20.628Z", "description": "Proposal to remove AnyCompany from supply chain |
amazon-managed-blockchain-hyperledger-fabric-dev-032 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 32 | Managed Blockchain (AMB) Network n-MWY63ZJZU5HGNCMBQER7IN6OIU and it will expire at 2016-12-16 20:42 UTC." } } Proposal State Change Event The detail-type of these messages is Managed Blockchain Proposal State Change. The following example shows an event for a proposal that changed state to APPROVED. { "version": "0", "id": "abcd1234-eeee-4321-a1a2-123456789012", "detail-type": "Managed Blockchain Proposal State Change", Example AMB Access Events 88 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "source": "aws.managedblockchain", "account": "123456789012", "time": "2019-04-08T23:40:20.628Z", "region": "us-east-1", "resources": [], "detail": { "proposalId": "p-ZR7KUD2YYNESLNG6RQ33X3FUFE", "networkId": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "status": "APPROVED", "proposedByMemberId": "m-K46ICRRXJRCGRNNS4ES4XUUS5A", "proposedByMemberName": "NetworkMember1", "expirationDate": "2019-04-09T23:40:20.628Z", "description": "Proposal to remove AnyCompany from supply chain blockchain network.", "message": "Voting on proposal p-ZR7KUD2YYNESLNG6RQ33X3FUFE in Amazon Managed Blockchain (AMB) Network n-MWY63ZJZU5HGNCMBQER7IN6OIU completed at 2016-19-16T20:10:50Z UTC and the proposal was approved." } } Example AMB Access Events 89 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Work with Hyperledger Fabric Components and Chaincode You access services and applications in AMB Access Hyperledger Fabric from a framework client machine. The client runs tools and applications that you install for the version of Hyperledger Fabric on the network. The client accesses AMB Access endpoints for components such as the CA, the orderer, and peer nodes through an interface VPC endpoint that you set up in your AWS account. The client machine must have access to the interface VPC endpoint to access resource endpoints. For more information, see Create an Interface VPC Endpoint for Amazon Managed Blockchain (AMB) Hyperledger Fabric. You can get the endpoints that networks, members, and peer nodes make available using the AWS Management Console, or using get commands and actions with the AMB Access AWS CLI or SDK. An AWS CloudFormation template to create a Hyperledger Fabric client is available in the amazon- managed-blockchain-client-templates repository on Github. For more information, see the readme.md in that repository. For more information about using AWS CloudFormation, see Getting Started in the AWS CloudFormation User Guide. Topics • Register and Enroll a Hyperledger Fabric Admin • Work with Channels • Add an Anchor Peer to a Channel • Develop Hyperledger Fabric Chaincode Register and Enroll a Hyperledger Fabric Admin Only identities who are admins within a Hyperledger Fabric member can install and query chaincode. Creating an admin in Hyperledger Fabric is a three-step process. 1. You register the identity with the Hyperledger Fabric CA. Registering stores the user name and password in the CA database as an admin. Create an Admin 90 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide 2. After you register, you enroll the identity. This sends the CA a Certificate Signing Request (CSR). The CA validates that the identity is registered and otherwise valid, and returns a signed certificate. The certificate is stored in the Hyperledger Fabric client machine's local Membership Service Provider (MSP). 3. You then copy the certificate to the admincerts subdirectory, and the certificate validates the role of the identity as an admin. Similarly, the CA updates the local MSP for the member's peer nodes and the ordering service so that the admin is recognized. For more information, see Fabric CA User's Guide and Membership in Hyperledger Fabric documentation. When you first create a member in a Hyperledger Fabric network on AMB Access, you specify the member's first user. AMB Access registers the identity of this user automatically with the Hyperledger Fabric CA. This is called a bootstrap identity. Even though the identity is registered, the remaining steps need to be performed. The identity must then enroll itself as an admin and certificates must be updated. After the steps are complete, the identity can install chaincode and can be used to enroll additional identities as admins. After you enroll an identity as an admin, it may take a minute or two until the identity is able to use the admin certificate to perform tasks. Important AMB Access does not support revoking user certificates. After an admin is created, the admin persists for the life of the member. To register and enroll an identity as an admin, you must have the following: • The member CA endpoint • The user name and password either of the bootstrap identity or of an admin with permissions to register and enroll identities • A valid certificate file and the path to the MSP directory of your identity, which will register the new administrator Create an Admin 91 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Registering an Admin The following example uses a Fabric-CA Client CLI register command to register an admin with these options: • --url specifies the endpoint of the CA along with an existing user name of an admin with permissions to register, such as the bootstrap identity. The example uses a user name of Example-AdminUser with password Example-Password123. • --id.name and --id.secret parameters establish the user name and password for the new admin. • |
amazon-managed-blockchain-hyperledger-fabric-dev-033 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 33 | the path to the MSP directory of your identity, which will register the new administrator Create an Admin 91 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Registering an Admin The following example uses a Fabric-CA Client CLI register command to register an admin with these options: • --url specifies the endpoint of the CA along with an existing user name of an admin with permissions to register, such as the bootstrap identity. The example uses a user name of Example-AdminUser with password Example-Password123. • --id.name and --id.secret parameters establish the user name and password for the new admin. • --id.type is set to user and --id.affiliation is set to the member name to which the admins belong. The example member name is org1. • --id.attrs is set to 'hf.admin=true'. This is a property specific to AMB Access that registers the identity as an admin. • The --tls.certfiles option specifies the location and file name of the AMB Access TLS certificate that you copied from Amazon S3 (see Step 5.1: Create the Certificate File). • --mspdir specifies the MSP directory on the local machine where certificates are saved. The example uses /home/ec2-user/admin-msp. fabric-ca-client register \ –-url https://Example-AdminUser:Example-Password123@ca.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-1.amazonaws.com:30002 \ --id.name AdminUser2 --id.secret Password456 \ –-id.type user --id.affiliation org1 \ --id.attrs ‘hf.Admin=true’ --tls.certfiles /home/ec2-user/managedblockchain-tls- chain.pem \ --mspdir /home/ec2-user/admin-msp Enrolling an Admin After registering an identity as an admin, or creating a member along with the bootstrap identity, you can use the Fabric-CA Client CLI enroll command to enroll that identity as an admin. This is shown in the following example using these options: • -u (an alternative for --url) specifies the endpoint of the CA along with the user name and password of the identity that you are enrolling. Registering an Admin 92 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • tls.certfiles specifies the location and file name of the AMB Access TLS certificate that you copied from Amazon S3 (see Step 5.1: Create the Certificate File). • -M (an alternative for --mspdir) specifies the MSP directory on the local machine where certificates are saved. The example uses /home/ec2-user/admin-msp. fabric-ca-client enroll \ -u https://Example-AdminUser:Example-Password123@ca.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-1.amazonaws.com:30002 \ --tls.certfiles /home/ec2-user/managedblockchain-tls-chain.pem \ -M /home/ec2-user/admin-msp Copying the Admin Certificate After you enroll the admin, copy the certificates from the signcerts directory to the admincerts directory as shown in the following example. The MSP directory /home/ec2-user/ admin-msp is used in the example, and the example assumes that you are running the command in the /home/ec2-user directory. cp -r admin-msp/signcerts admin-msp/admincerts Work with Channels A channel is a private communication pathway between two or more members of a Hyperledger Fabric network on Amazon Managed Blockchain (AMB). Each transaction on a Hyperledger Fabric network occurs on a channel. A network must contain at least one channel and a network on AMB Access can have up to eight channels. Each channel has its own transaction ledger. The ordering service on the network manages transactions according to a channel configuration that a member creates. The channel configuration specifies which members participate in the channel, the peer nodes that can transact on the channel, and the policies that govern channel updates. To participate on a channel, a member must join at least one peer node to the channel. A peer node can belong to multiple channels, but ledger data from one channel can't pass to ledger data in another channel. A member shares their admin certificates and root CA with the channel creator when they join the channel. These artifacts allow the ordering service to authenticate and authorize members of the channel when they join their peer nodes to the channel. Copying the Admin Certificate 93 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Optionally, a channel also can contain private data collections. A private data collection allows a subset of channel members to share ledger data independently of the ordering service. Private data collections are supported only with Hyperledger Fabric 1.4 or later. Private data collections require that at least one peer node for a member is set up as an anchor peer. For more information, see Add an Anchor Peer to a Channel and Work with Private Data Collections in AMB Access Hyperledger Fabric. Create a Channel A channel creator is a member that uses their Hyperledger Fabric client to create a channel configuration file. The channel creator then runs a command that outputs a channel transaction file based on that configuration file. Finally, the channel creator uses the transaction file to run a command that creates the channel with the Hyperledger Fabric ordering service on AMB Access. The channel creator must get security artifacts from channel members to be able to add the members to the channel. After the channel is created, channel members, including the channel creator, download the channel genesis block to their respective Hyperledger |
amazon-managed-blockchain-hyperledger-fabric-dev-034 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 34 | channel creator is a member that uses their Hyperledger Fabric client to create a channel configuration file. The channel creator then runs a command that outputs a channel transaction file based on that configuration file. Finally, the channel creator uses the transaction file to run a command that creates the channel with the Hyperledger Fabric ordering service on AMB Access. The channel creator must get security artifacts from channel members to be able to add the members to the channel. After the channel is created, channel members, including the channel creator, download the channel genesis block to their respective Hyperledger Fabric client machines and join peer nodes to the channel. To create and join a Hyperledger Fabric channel on AMB Access The following steps specify file locations in terms of both the Hyperledger Fabric client machine's file system and the Hyperledger Fabric CLI Docker container file system, as appropriate. When the CLI is installed, the Docker Compose configuration file maps these locations to one another. For more information, see step 4.4 in the Getting Started tutorial of this guide. In the following examples, the client machine directory /home/ec2-user is mapped to the container directory /opt/home. In steps where you save artifacts, the steps use the client machine file system. In steps where you reference artifacts in CLI commands and configuration files, the steps use the container file system. 1. Each member that joins a channel shares its security artifacts with the channel creator. The channel creator saves the artifacts on the Hyperledger Fabric client machine. The channel creator then references the location of these artifacts in the next step. For more information about sharing artifacts, see Step 8.4 and 8.5 in the getting started tutorial of this guide. Sharing artifacts is a prerequisite for the steps below. 2. On your Hyperledger Fabric client machine, create a configuration file in yaml format named configtx.yaml. Save this file to a file location on your Hyperledger Fabric client machine Create a Channel 94 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide that is mapped to the CLI container file system. The following steps use /home/ec2-user, which is mapped to /opt/home. Use the examples below as a starting point. For more information about configuration files, see Channel configuration (configtx) in the Hyperledger Fabric documentation. Replace the following configuration parameters as appropriate for your channel, and add sections as required for additional members. • Org<n>MemberID is the respective member ID for each channel participant, for example, m- K46ICRRXJRCGRNNS4ES4XUUS5A. • Org<n>AdminMSPDir is the Docker container file system directory where security artifacts for each corresponding member are saved. For example, /opt/home/Org2AdminMSP references artifacts saved to /home/ec2-user/Org2AdminMSP on the channel creator's client machine. The configtx file for a network on Hyperledger Fabric 1.4 or later includes application settings to enable expanded features. These settings are not supported in Hyperledger Fabric 1.2 channels. Examples for version 1.2, 1.4, and 2.2 networks are provided below. Version 2.2 ################################################################################ # # ORGANIZATIONS # # This section defines the organizational identities that can be referenced # in the configuration profiles. # ################################################################################ Organizations: # Org1 defines an MSP using the sampleconfig. It should never be used # in production but may be used as a template for other definitions. - &Org1 # Name is the key by which this org will be referenced in channel # configuration transactions. # Name can include alphanumeric characters as well as dots and dashes. Name: Org1MemberID # ID is the key by which this org's MSP definition will be referenced. # ID can include alphanumeric characters as well as dots and dashes. ID: Org1MemberID Create a Channel 95 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # SkipAsForeign can be set to true for org definitions which are to be # inherited from the orderer system channel during channel creation. This # is especially useful when an admin of a single org without access to the # MSP directories of the other orgs wishes to create a channel. Note # this property must always be set to false for orgs included in block # creation. SkipAsForeign: false Policies: &Org1Policies Readers: Type: Signature Rule: "OR('Org1.member', 'Org2.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.peer', 'Org1.client')" Writers: Type: Signature Rule: "OR('Org1.member', 'Org2.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.client')" Admins: Type: Signature Rule: "OR('Org1.admin')" # MSPDir is the filesystem path which contains the MSP configuration. MSPDir: /opt/home/Org1AdminMSP # AnchorPeers defines the location of peers which can be used for # cross-org gossip communication. Note, this value is only encoded in # the genesis block in the Application section context. |
amazon-managed-blockchain-hyperledger-fabric-dev-035 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 35 | might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.peer', 'Org1.client')" Writers: Type: Signature Rule: "OR('Org1.member', 'Org2.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.client')" Admins: Type: Signature Rule: "OR('Org1.admin')" # MSPDir is the filesystem path which contains the MSP configuration. MSPDir: /opt/home/Org1AdminMSP # AnchorPeers defines the location of peers which can be used for # cross-org gossip communication. Note, this value is only encoded in # the genesis block in the Application section context. AnchorPeers: - Host: 127.0.0.1 Port: 7051 - &Org2 Name: Org2MemberID ID: Org2MemberID SkipAsForeign: false Policies: &Org2Policies Readers: Type: Signature Rule: "OR('Org2.member', 'Org1.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.peer', 'Org1.client')" Create a Channel 96 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Writers: Type: Signature Rule: "OR('Org2.member', 'Org1.member')" # If your MSP is configured with the new NodeOUs, you might # want to use a more specific rule like the following: # Rule: "OR('Org1.admin', 'Org1.client')" Admins: Type: Signature Rule: "OR('Org2.admin')" # MSPDir is the filesystem path which contains the MSP configuration. MSPDir: /opt/home/Org2AdminMSP # AnchorPeers defines the location of peers which can be used for # cross-org gossip communication. Note, this value is only encoded in # the genesis block in the Application section context. AnchorPeers: - Host: 127.0.0.1 Port: 7052 ################################################################################ # # CAPABILITIES # # This section defines the capabilities of fabric network. This is a new # concept as of v1.1.0 and should not be utilized in mixed networks with # v1.0.x peers and orderers. Capabilities define features which must be # present in a fabric binary for that binary to safely participate in the # fabric network. For instance, if a new MSP type is added, newer binaries # might recognize and validate the signatures from this type, while older # binaries without this support would be unable to validate those # transactions. This could lead to different versions of the fabric binaries # having different world states. Instead, defining a capability for a channel # informs those binaries without this capability that they must cease # processing transactions until they have been upgraded. For v1.0.x if any # capabilities are defined (including a map with all capabilities turned off) # then the v1.0.x peer will deliberately crash. # ################################################################################ Capabilities: # Channel capabilities apply to both the orderers and the peers and must be # supported by both. # Set the value of the capability to true to require it. # Note that setting a later Channel version capability to true will also # implicitly set prior Channel version capabilities to true. There is no need # to set each version capability to true (prior version capabilities remain Create a Channel 97 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # in this sample only to provide the list of valid values). Channel: &ChannelCapabilities # V2.0 for Channel is a catchall flag for behavior which has been # determined to be desired for all orderers and peers running at the v2.0.0 # level, but which would be incompatible with orderers and peers from # prior releases. # Prior to enabling V2.0 channel capabilities, ensure that all # orderers and peers on a channel are at v2.0.0 or later. V2_0: true # Orderer capabilities apply only to the orderers, and may be safely # used with prior release peers. # Set the value of the capability to true to require it. Orderer: &OrdererCapabilities # V1.1 for Orderer is a catchall flag for behavior which has been # determined to be desired for all orderers running at the v1.1.x # level, but which would be incompatible with orderers from prior releases. # Prior to enabling V2.0 orderer capabilities, ensure that all # orderers on a channel are at v2.0.0 or later. V2_0: true # Application capabilities apply only to the peer network, and may be safely # used with prior release orderers. # Set the value of the capability to true to require it. # Note that setting a later Application version capability to true will also # implicitly set prior Application version capabilities to true. There is no need # to set each version capability to true (prior version capabilities remain # in this sample only to provide the list of valid values). Application: &ApplicationCapabilities # V2.0 for Application enables the new non-backwards compatible # features and fixes of fabric v2.0. # Prior to enabling V2.0 orderer capabilities, ensure that all # orderers on a channel are at v2.0.0 or later. V2_0: true ################################################################################ # # CHANNEL # # This section defines the values to encode |
amazon-managed-blockchain-hyperledger-fabric-dev-036 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 36 | setting a later Application version capability to true will also # implicitly set prior Application version capabilities to true. There is no need # to set each version capability to true (prior version capabilities remain # in this sample only to provide the list of valid values). Application: &ApplicationCapabilities # V2.0 for Application enables the new non-backwards compatible # features and fixes of fabric v2.0. # Prior to enabling V2.0 orderer capabilities, ensure that all # orderers on a channel are at v2.0.0 or later. V2_0: true ################################################################################ # # CHANNEL # # This section defines the values to encode into a config transaction or # genesis block for channel related parameters. # ################################################################################ Channel: &ChannelDefaults Create a Channel 98 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # Policies defines the set of policies at this level of the config tree # For Channel policies, their canonical path is # /Channel/<PolicyName> Policies: # Who may invoke the 'Deliver' API Readers: Type: ImplicitMeta Rule: "ANY Readers" # Who may invoke the 'Broadcast' API Writers: Type: ImplicitMeta Rule: "ANY Writers" # By default, who may modify elements at this config level Admins: Type: ImplicitMeta Rule: "MAJORITY Admins" # Capabilities describes the channel level capabilities, see the # dedicated Capabilities section elsewhere in this file for a full # description Capabilities: <<: *ChannelCapabilities ################################################################################ # # APPLICATION # # This section defines the values to encode into a config transaction or # genesis block for application-related parameters. # ################################################################################ Application: &ApplicationDefaults # Organizations is the list of orgs which are defined as participants on # the application side of the network Organizations: # Policies defines the set of policies at this level of the config tree # For Application policies, their canonical path is # /Channel/Application/<PolicyName> Policies: &ApplicationDefaultPolicies LifecycleEndorsement: Type: ImplicitMeta Rule: "ANY Readers" Endorsement: Type: ImplicitMeta Rule: "ANY Readers" Readers: Create a Channel 99 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Type: ImplicitMeta Rule: "ANY Readers" Writers: Type: ImplicitMeta Rule: "ANY Writers" Admins: Type: ImplicitMeta Rule: "MAJORITY Admins" Capabilities: <<: *ApplicationCapabilities ################################################################################ # # PROFILES # # Different configuration profiles may be encoded here to be specified as # parameters to the configtxgen tool. The profiles which specify consortiums # are to be used for generating the orderer genesis block. With the correct # consortium members defined in the orderer genesis block, channel creation # requests may be generated with only the org member names and a consortium # name. # ################################################################################ Profiles: TwoOrgChannel: <<: *ChannelDefaults Consortium: AWSSystemConsortium Application: <<: *ApplicationDefaults Organizations: - *Org1 - *Org2 Version 1.4 ################################################################################ # # Section: Organizations # # - This section defines the different organizational identities which will # be referenced later in the configuration. # ################################################################################ Create a Channel 100 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Organizations: - &Org1 # member id defines the organization Name: Org1MemberID # ID to load the MSP definition as ID: Org1MemberID #msp dir of org1 in the docker container MSPDir: /opt/home/Org1AdminMSP # AnchorPeers defines the location of peers which can be used # for cross org gossip communication. Note, this value is only # encoded in the genesis block in the Application section context AnchorPeers: - Host: Port: - &Org2 Name: Org2MemberID ID: Org2MemberID #msp dir of org2 in the docker container MSPDir: /opt/home/Org2AdminMSP AnchorPeers: - Host: Port: ################################################################################ # # CAPABILITIES # # This section defines the capabilities of fabric network. This is a new # concept as of v1.1.0 and should not be utilized in mixed networks with # v1.0.x peers and orderers. Capabilities define features which must be # present in a fabric binary for that binary to safely participate in the # fabric network. For instance, if a new MSP type is added, newer binaries # might recognize and validate the signatures from this type, while older # binaries without this support would be unable to validate those # transactions. This could lead to different versions of the fabric binaries # having different world states. Instead, defining a capability for a channel # informs those binaries without this capability that they must cease # processing transactions until they have been upgraded. For v1.0.x if any # capabilities are defined (including a map with all capabilities turned off) # then the v1.0.x peer will deliberately crash. # ################################################################################ Capabilities: # Channel capabilities apply to both the orderers and the peers and must be # supported by both. Create a Channel 101 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # Set the value of the capability to true to require it. # Note that setting a later Channel version capability to true will also # implicitly set prior Channel version capabilities to true. There is no need # to set each version capability to true (prior version capabilities remain # in |
amazon-managed-blockchain-hyperledger-fabric-dev-037 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 37 | a map with all capabilities turned off) # then the v1.0.x peer will deliberately crash. # ################################################################################ Capabilities: # Channel capabilities apply to both the orderers and the peers and must be # supported by both. Create a Channel 101 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # Set the value of the capability to true to require it. # Note that setting a later Channel version capability to true will also # implicitly set prior Channel version capabilities to true. There is no need # to set each version capability to true (prior version capabilities remain # in this sample only to provide the list of valid values). Channel: &ChannelCapabilities # V1.4.3 for Channel is a catchall flag for behavior which has been # determined to be desired for all orderers and peers running at the v1.4.3 # level, but which would be incompatible with orderers and peers from # prior releases. # Prior to enabling V1.4.3 channel capabilities, ensure that all # orderers and peers on a channel are at v1.4.3 or later. V1_4_3: true # V1.3 for Channel enables the new non-backwards compatible # features and fixes of fabric v1.3 V1_3: false # V1.1 for Channel enables the new non-backwards compatible # features and fixes of fabric v1.1 V1_1: false # Application capabilities apply only to the peer network, and may be safely # used with prior release orderers. # Set the value of the capability to true to require it. # Note that setting a later Application version capability to true will also # implicitly set prior Application version capabilities to true. There is no need # to set each version capability to true (prior version capabilities remain # in this sample only to provide the list of valid values). Application: &ApplicationCapabilities # V1.4.2 for Application enables the new non-backwards compatible # features and fixes of fabric v1.4.2 V1_4_2: true # V1.3 for Application enables the new non-backwards compatible # features and fixes of fabric v1.3. V1_3: false # V1.2 for Application enables the new non-backwards compatible # features and fixes of fabric v1.2 (note, this need not be set if # later version capabilities are set) V1_2: false # V1.1 for Application enables the new non-backwards compatible # features and fixes of fabric v1.1 (note, this need not be set if # later version capabilities are set). V1_1: false Create a Channel 102 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide ################################################################################ # # SECTION: Application # # - This section defines the values to encode into a config transaction or # genesis block for application related parameters # ################################################################################ Application: &ApplicationDefaults # Organizations is the list of orgs which are defined as participants on # the application side of the network Organizations: Capabilities: <<: *ApplicationCapabilities ################################################################################ # # Profile # # - Different configuration profiles may be encoded here to be specified # as parameters to the configtxgen tool # ################################################################################ Profiles: TwoOrgChannel: Consortium: AWSSystemConsortium Application: <<: *ApplicationDefaults Organizations: - *Org1 - *Org2 Version 1.2 ################################################################################ # # Section: Organizations # # - This section defines the different organizational identities which will # be referenced later in the configuration. # ################################################################################ Organizations: - &Org1 Create a Channel 103 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide # member id defines the organization Name: Member1ID # ID to load the MSP definition as ID: Member1ID #msp dir of org1 in the docker container MSPDir: /opt/home/Org1AdminMSP # AnchorPeers defines the location of peers which can be used # for cross org gossip communication. Note, this value is only # encoded in the genesis block in the Application section context AnchorPeers: - Host: Port: - &Org2 Name: Member2ID ID: Member2ID MSPDir: /opt/home/Org2AdminMSP AnchorPeers: - Host: Port: ################################################################################ # # SECTION: Application # # - This section defines the values to encode into a config transaction or # genesis block for application related parameters # ################################################################################ Application: &ApplicationDefaults # Organizations is the list of orgs which are defined as participants on # the application side of the network Organizations: ################################################################################ # # Profile # # - Different configuration profiles may be encoded here to be specified # as parameters to the configtxgen tool # ################################################################################ Profiles: TwoOrgChannel: Consortium: AWSSystemConsortium Create a Channel 104 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Application: <<: *ApplicationDefaults Organizations: - *Org1 - *Org2 3. The channel creator uses the Hyperledger Fabric CLI configtxgen command as shown in the following example to write a channel creation transaction. Replace the following configuration parameters as appropriate for your channel. • /opt/home/ourchannel.pb is the channel creation transaction file that the command creates. Specify the file location using the container file system. • TwoOrgChannel is the profile specified in the configtx.yaml from the previous step. • ourchannel is the channel ID that will be used for |
amazon-managed-blockchain-hyperledger-fabric-dev-038 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 38 | Consortium: AWSSystemConsortium Create a Channel 104 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Application: <<: *ApplicationDefaults Organizations: - *Org1 - *Org2 3. The channel creator uses the Hyperledger Fabric CLI configtxgen command as shown in the following example to write a channel creation transaction. Replace the following configuration parameters as appropriate for your channel. • /opt/home/ourchannel.pb is the channel creation transaction file that the command creates. Specify the file location using the container file system. • TwoOrgChannel is the profile specified in the configtx.yaml from the previous step. • ourchannel is the channel ID that will be used for the channel. • /opt/home/ for the --configPath option is the container location where the configtx.yaml file is saved. docker exec cli configtxgen \ -outputCreateChannelTx /opt/home/ourchannel.pb \ -profile TwoOrgChannel -channelID ourchannel \ --configPath /opt/home/ 4. The channel creator uses the Hyperledger Fabric CLI channel create command to create a channel and write the genesis block to the orderer. The -f option specifies the transaction file that you created in the previous step, and the $ORDERER environment variable in the example has been set to the endpoint of the network orderer for simplicity—for example, orderer.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001. docker exec cli peer channel create -c ourchannel \ -f /opt/home/ourchannel.pb -o $ORDERER \ --cafile /opt/home/managedblockchain-tls-chain.pem --tls 5. To join a peer node to the channel, each member must fetch the channel genesis block from the orderer, write it to a file, and then reference that genesis block when they join their peer or peers. a. To get the channel genesis block, each member uses the Hyperledger Fabric CLI peer channel fetch oldest command. In the following example, the genesis block is written Create a Channel 105 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide to a file in the container file system, /opt/home/ourchannel.block. The $ORDERER variable is used in the same ways the previous step, and the ourchannel channel ID is specified. docker exec cli peer channel fetch oldest /opt/home/ourchannel.block \ -c ourchannel -o $ORDERER \ --cafile /opt/home/managedblockchain-tls-chain.pem --tls b. Using the channel genesis block file created above, each member uses the Hyperledger Fabric peer channel join command to join their member's peer node to the channel. docker exec cli peer channel join -b /opt/home/ourchannel.block \ -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls Add an Anchor Peer to a Channel Anchor peers within an organization enable cross-organization communication among peer nodes using the Hyperledger Fabric gossip protocol. In general, the gossip protocol identifies other available member peers, disseminates ledger data across peers on a channel, and brings new peers up to date quickly. Although anchor peers are not strictly required for an organization on a channel, at least one anchor peer is required for an organization to participate in features that use the gossip protocol, such as private data collections and service discovery. In addition, we recommend that an organization creates redundant anchor peers on a channel for resiliency. For more information, see Anchor Peer and Gossip data dissemination protocol in the Hyperledger Fabric documentation. The steps in this section demonstrate how you can update a channel configuration to add a peer as an anchor peer for your organization in Amazon Managed Blockchain (AMB). The peer that you want to designate as an anchor peer for your organization must first be joined to the channel. Prerequisites and Assumptions The steps in this section are based on the assumption that you are using a network, client machine, member, peer, and joint channel similar to those that you create during the getting started tutorial in this guide. The example commands shown presume that the environment variables, the directory locations on the client machine, the locations in the Docker container, the properties of members and peer Add an Anchor Peer to a Channel 106 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide nodes, and the properties of the joint channel from that tutorial are being used. You might find it useful to review that information before running these commands. For more information, see the following resources: • Create a client • Enroll an administrator • Create the peer node • Create a multi-member channel • Join the peer node to the channel Adding a Peer as an Anchor Peer A peer node must already be joined to a channel to be set up as an anchor peer. To update a peer to be an anchor peer, you download a configuration file from the orderer on the Amazon Managed Blockchain (AMB) Hyperledger Fabric network into a directory that you create on the Hyperledger Fabric client. Next, you use the configtxlator command and the jq tool to manipulate the original protobuf configuration file between protobuf and JSON. Then you use your final protobuf file to update the channel configuration in the orderer. 1. Create a directory on your Hyperledger Fabric client machine, |
amazon-managed-blockchain-hyperledger-fabric-dev-039 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 39 | peer node must already be joined to a channel to be set up as an anchor peer. To update a peer to be an anchor peer, you download a configuration file from the orderer on the Amazon Managed Blockchain (AMB) Hyperledger Fabric network into a directory that you create on the Hyperledger Fabric client. Next, you use the configtxlator command and the jq tool to manipulate the original protobuf configuration file between protobuf and JSON. Then you use your final protobuf file to update the channel configuration in the orderer. 1. Create a directory on your Hyperledger Fabric client machine, channel-artifacts, that you can use to save channel configuration artifacts that you create. cd /home/ec2-user mkdir channel-artifacts 2. Use the Hyperledger Fabric peer channel fetch sub-command to get the channel configuration and save it locally, as shown in the following command. In this example, ourchannel is the Channel ID. This Channel ID is the same one established in the step for creating the multi-member channel in the Getting Started tutorial of this guide. The command saves the configuration file to the directory you created in a protobuf file named ourchannelCfg.pb. docker exec cli peer channel fetch config \ /opt/home/channel-artifacts/ourchannelCfg.pb \ -c ourchannel -o $ORDERER \ Adding a Peer as an Anchor Peer 107 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide --cafile /opt/home/managedblockchain-tls-chain.pem --tls 3. Decode the ourchannelCfg.pb configuration from protobuf into a JSON object as shown in the following command. docker exec cli configtxlator proto_decode \ --input /opt/home/channel-artifacts/ourchannelCfg.pb --type common.Block \ --output /opt/home/channel-artifacts/config_block.json 4. Switch directories to the channel-artifacts directory. cd channel-artifacts 5. Convert the JSON object that you created from the protobuf file into a streamlined JSON file named config.json, and then copy it to config_copy.json, as shown in the following commands. sudo jq .data.data[0].payload.data.config config_block.json > config.json cp config.json config_copy.json 6. Use the jq tool to modify the config_copy.json configuration file by adding an anchor peer and to save the modifications to a new JSON configuration file named modified_config.json as shown in the following command. Replace the items below as appropriate for your AMB Access member, network, and peer configuration. • OrgMemberID is the ID of a AMB Access member that belongs to the channel and owns the peer node that will be an anchor peer. For example, m-K46ICRRXJRCGRNNS4ES4XUUS5A. • PeerNodeDNS is the endpoint, minus the port identifier, of the peer node. For example, nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-1.amazonaws.com. • PortNumber is the port number included in the peer node endpoint in the console or the PeerEndpoint in the Amazon Managed Blockchain (AMB) API for the peer. For example 30003. jq '.channel_group.groups.Application.groups["OrgMemberID"].values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": Adding a Peer as an Anchor Peer 108 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "PeerNodeDNS","port": PortNumber}]},"version": "0"}}' config_copy.json > modified_config.json 7. Return the configuration JSON files to protobuf format, calculate the difference between them, and then generate a new config_update.json configuration file as shown in the following commands. docker exec cli configtxlator proto_encode \ --input /opt/home/channel-artifacts/config.json \ --type common.Config \ --output /opt/home/channel-artifacts/config.pb docker exec cli configtxlator proto_encode \ --input /opt/home/channel-artifacts/modified_config.json \ --type common.Config \ --output /opt/home/channel-artifacts/modified_config.pb docker exec cli configtxlator compute_update \ --channel_id ourchannel \ --original /opt/home/channel-artifacts/config.pb \ --updated /opt/home/channel-artifacts/modified_config.pb \ --output /opt/home/channel-artifacts/config_update.pb docker exec cli configtxlator proto_decode \ --input /opt/home/channel-artifacts/config_update.pb \ --type common.ConfigUpdate \ --output /opt/home/channel-artifacts/config_update.json 8. Change permissions for the config_update.json file you created above so that you can pipe its contents along with transaction envelope parameters to the jq tool and create the config_update_in_envelope.json file, as shown in the following commands. sudo chmod 755 config_update.json echo '{"payload":{"header":{"channel_header":{"channel_id":"ourchannel", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . > config_update_in_envelope.json Adding a Peer as an Anchor Peer 109 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide 9. Convert the config_update_in_envelope.json file to a config_update_in_envelope.pb configuration file in protobuf format as shown in the following command. docker exec cli configtxlator proto_encode --input /opt/home/channel-artifacts/ config_update_in_envelope.json --type common.Envelope --output /opt/home/channel- artifacts/config_update_in_envelope.pb 10. Specify the config_update_in_envelope.pb configuration file to update the channel configuration on the orderer for the AMB Access Hyperledger Fabric network as shown in the following command. docker exec cli peer channel update \ -f /opt/home/channel-artifacts/config_update_in_envelope.pb \ -c ourchannel -o $ORDERER \ --cafile /opt/home/managedblockchain-tls-chain.pem --tls Develop Hyperledger Fabric Chaincode Smart contracts in Hyperledger Fabric are known as chaincode. • For a conceptual overview of chaincode, see Smart Contracts and Developing Applications in the Hyperledger Fabric documentation. • For links to Hyperledger Fabric SDKs, see Getting Started in the Hyperledger Fabric documentation. • Hyperledger Fabric 2.x introduces decentralized governance for smart contracts. This includes a new Fabric chaincode lifecycle that enables multiple organizations in a network to come to agreement on the parameters of a chaincode. For more information, see Decentralized governance for smart contracts in the Hyperledger Fabric documentation. Considerations and Limitations When Developing Chaincode for AMB Access • All Hyperledger Fabric networks on AMB Access support |
amazon-managed-blockchain-hyperledger-fabric-dev-040 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 40 | chaincode. • For a conceptual overview of chaincode, see Smart Contracts and Developing Applications in the Hyperledger Fabric documentation. • For links to Hyperledger Fabric SDKs, see Getting Started in the Hyperledger Fabric documentation. • Hyperledger Fabric 2.x introduces decentralized governance for smart contracts. This includes a new Fabric chaincode lifecycle that enables multiple organizations in a network to come to agreement on the parameters of a chaincode. For more information, see Decentralized governance for smart contracts in the Hyperledger Fabric documentation. Considerations and Limitations When Developing Chaincode for AMB Access • All Hyperledger Fabric networks on AMB Access support a maximum of 8 channels per network, regardless of network edition. • Hyperledger Fabric Shims for Node.js Develop Chaincode 110 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide To simplify chaincode development, AMB Access includes versions of the fabric-shim library. This library provides a low-level chaincode interface between applications, peers, and the Hyperledger Fabric system for chaincode applications developed with Node.js. The library version is specified using the dependencies object in the package.json file bundled with your chaincode. You can specify a version explicitly or use the semantic versioner (semver) for NPM to specify a version range. The following library versions are available without bundling. • Hyperledger Fabric 1.4 • 1.4.0 • 1.4.1 • 1.4.2 • 1.4.4 • 1.4.5 • Hyperledger Fabric 1.2 • 1.2.0 • 1.2.2 • 1.2.3 • 1.2.4 Dependencies on other versions of fabric-shim or other library packages require that you bundle them with your chaincode because peer nodes do not have internet access to the NPM repository. AMB Access doesn't currently include fabric-shim for Hyperledger Fabric 2.2. You need to bundle this version of the library in your Node.js application. • The default limit for the size of a transaction payload is 1MB. To request a limit increase, create a case using the AWS Support Center. • AMB Access doesn't support the External chaincode launcher in Hyperledger Fabric 2.2. This feature requires that you modify a peer's core.yaml file, which you don't currently have access to. Topics • Work with Private Data Collections in AMB Access Hyperledger Fabric • Develop Hyperledger Fabric Chaincode Using Java on Amazon Managed Blockchain (AMB) Considerations and Limitations When Developing Chaincode for AMB Access 111 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Work with Private Data Collections in AMB Access Hyperledger Fabric Network members that participate on a Hyperledger Fabric channel on AMB Access may want to keep some data private from other members on the same channel. Hyperledger Fabric private data collections allow you to accomplish this. Private data collections allow a subset of members on a channel to endorse, commit, and query private data without having to create a separate channel to exclude other members. Private data reduces the overhead associated with channel creation and maintenance. In addition, private data is disseminated only between authorized peers using the Hyperledger Fabric gossip protocol, so the data is kept confidential from the ordering service. To create a private data collection, a peer creates a private data definition. The definition establishes the members who have access to the private data collection. It also defines a policy that governs how transactions are endorsed and committed. Private data is stored on each peer node in a way that is accessible to the peer chaincode and logically distinct from other channel transaction data. This helps ensure that channel members who are not specified in the private data definition cannot access the private data. For more information about private data collections, see Private Data and the Private Data architecture topic in the Hyperledger Fabric documentation. Hyperledger Fabric version 2.x introduces collection-level endorsement policies that can override the endorsement policy set at the chaincode level. To learn more, see Sharing private data in the Hyperledger Fabric documentation. Private data collections with Amazon Managed Blockchain (AMB) require the following: • A network created using Hyperledger Fabric version 1.4 or later. • A channel configuration that supports the latest features of your version. The multi-member channel configuration featured in the Getting Started tutorial of this guide enables the latest features. • At least one anchor peer for each member that participates in the private data collection. This is because Hyperledger Fabric uses the gossip protocol to distribute private data to authorized peers. For more information, see Add an Anchor Peer to a Channel. Private Data Collections 112 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Develop Hyperledger Fabric Chaincode Using Java on Amazon Managed Blockchain (AMB) Hyperledger Fabric 2.2 networks on Amazon Managed Blockchain (AMB) are based on the following components: • JDK 8 or higher • Hyperledger Fabric v2.2.4 • Hyperledger Fabric CA v1.4.7 • fabric-chaincode-java AMB Access Dependency on Javaenv Docker Image AMB Access uses the fabric-chaincode-java package to build the hyperledger/fabric- javaenv Docker image. This |
amazon-managed-blockchain-hyperledger-fabric-dev-041 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 41 | because Hyperledger Fabric uses the gossip protocol to distribute private data to authorized peers. For more information, see Add an Anchor Peer to a Channel. Private Data Collections 112 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Develop Hyperledger Fabric Chaincode Using Java on Amazon Managed Blockchain (AMB) Hyperledger Fabric 2.2 networks on Amazon Managed Blockchain (AMB) are based on the following components: • JDK 8 or higher • Hyperledger Fabric v2.2.4 • Hyperledger Fabric CA v1.4.7 • fabric-chaincode-java AMB Access Dependency on Javaenv Docker Image AMB Access uses the fabric-chaincode-java package to build the hyperledger/fabric- javaenv Docker image. This image is the base layer of the Java chaincode container. It has built-in support to build the Java chaincode using Gradle or Maven at the following versions: • gradle@5.6.2 • maven@3.8.1 You can verify this by examining the Docker file in the fabric-chaincode-java package. The default settings support Gradle or Maven for building Java chaincode. Once the javaenv Docker image is deployed, it is used to provision all new peer nodes and install Java chaincode in those peer nodes. You cannot modify these settings or update versions on the javaenv Docker image because AMB Access manages these. Installing and Running Java Chaincode The following is a high-level summary of the steps to install and run Java Chaincode using AMB Access with Hyperledger Fabric 2.2 1. Marshall dependencies locally – This step uses Gradle and the Gradle shadow plugin to download dependencies to the client machine and package them for installation to the peer node. 2. Install the chaincode – This step packages the Java chaincode project and copies it to the Hyperledger Fabric peer node. Develop Java Chaincode 113 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide 3. Invoke and query the chaincode – After, you can send query transactions or invoke transactions to modify the ledger. Building Java Chaincode with AMB Access: Step-by-step In a traditional installation of Hyperledger Fabric chaincode built with Java, Gradle automatically resolves dependencies by loading them locally in addition to downloading them from remote repositories. AMB Access does not allow downloaded dependencies to help ensure the security and reliability of the network. For this reason, to run Java chaincode, or any chaincode, in a Hyperledger Fabric network on AMB Access, you manually download dependencies to the client machine and add them into the chaincode project. The steps in this section demonstrate how to use Gradle to build and deploy a sample Java chaincode project with fabric-shim@2.2.1 to a Hyperledger Fabric network on AMB Access. The Gradle Shadow plugin is needed to combine all jar files into a single jar file. Prerequisites and Assumptions The steps below require that you have the following: Develop Java Chaincode 114 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • A Hyperledger Fabric client machine with access to the internet and access to a member's peer node, ordering service, and CA on an AMB Access network running Hyperledger Fabric v2.2 or later. For more information, see the following: • Create a Hyperledger Fabric Blockchain Network on Amazon Managed Blockchain (AMB) • Create an Interface VPC Endpoint for Amazon Managed Blockchain (AMB) Hyperledger Fabric • Work with Hyperledger Fabric Peer Nodes on AMB Access • Step 4: Create an Amazon EC2 Instance and Set Up the Hyperledger Fabric Client. Optionally, modify step 4.4 when launching the Docker container to establish CLI variables demonstrated in the install steps below. • You must be a Hyperledger Fabric admin to install chaincode. For more information, see Register and Enroll a Hyperledger Fabric Admin. Step 1: Download the Gradle Shadow plugin and add it to the chaincode project Because AMB Access peer nodes don't have internet access, the Gradle Shadow plugin needs to be downloaded manually to the client and added to the project. The plugin is downloaded from the Gradle plugin repository. 1. Create a sub-directory in the Java chaincode working directory on the Hyperledger Fabric client machine where you want to download the plugin, and then switch to that directory. The example below uses a directory named plugin. mkdir plugin cd plugin 2. Download the plugin. wget https://plugins.gradle.org/m2/com/github/jengelman/gradle/plugins/shadow/5.1.0/ shadow-5.1.0.jar 3. Verify that the plugin was downloaded as expected. ls shadow-5.1.0.jar 4. After downloading the shadow plugin jar file, use an editor to modify the build.gradle file so that it references the local directory and plugin. Develop Java Chaincode 115 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Make sure to remove the id 'com.github.johnrengelman.shadow' version '5.1.0' entry from the plugins section. The following example shows an excerpt from an edited build.gradle file, with relevant sections emphasized: buildscript { dependencies { classpath fileTree(dir: 'plugin', include:['*.jar']) } } plugins { id 'java' } group 'org.hyperledger.fabric-chaincode-java' version '1.0-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenLocal() mavenCentral() } dependencies { implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.+' } apply plugin: 'com.github.johnrengelman.shadow' shadowJar |
amazon-managed-blockchain-hyperledger-fabric-dev-042 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 42 | downloading the shadow plugin jar file, use an editor to modify the build.gradle file so that it references the local directory and plugin. Develop Java Chaincode 115 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Make sure to remove the id 'com.github.johnrengelman.shadow' version '5.1.0' entry from the plugins section. The following example shows an excerpt from an edited build.gradle file, with relevant sections emphasized: buildscript { dependencies { classpath fileTree(dir: 'plugin', include:['*.jar']) } } plugins { id 'java' } group 'org.hyperledger.fabric-chaincode-java' version '1.0-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenLocal() mavenCentral() } dependencies { implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.+' } apply plugin: 'com.github.johnrengelman.shadow' shadowJar { baseName = 'chaincode' version = null classifier = null manifest { attributes 'Main-Class': 'org.hyperledger.fabric_samples.ABstore' } } Develop Java Chaincode 116 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Step 2: Add fabric-chaincode-shim and the getDeps task to the chaincode project Update build.gradle to add fabric-chaincode-shim as a dependency in the dependencies section. In addition, reference the task getDeps to download dependencies to the libs sub- directory on the client machine. The following example shows an excerpt from a build.gradle file with relevant sections emphasized. buildscript { dependencies { classpath fileTree(dir: 'plugin', include:['*.jar']) } } plugins { id 'java' } group 'org.hyperledger.fabric-chaincode-java' version '1.0-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenLocal() mavenCentral() maven { url "https://hyperledger.jfrog.io/hyperledger/fabric-maven" } maven { url 'https://jitpack.io' } } dependencies { compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode- shim', version: '2.2.1' testCompile group: 'junit', name: 'junit', version: '4.12' } apply plugin: 'com.github.johnrengelman.shadow' shadowJar { baseName = 'chaincode' Develop Java Chaincode 117 Amazon Managed Blockchain (AMB) version = null classifier = null manifest { Hyperledger Fabric Developer Guide attributes 'Main-Class': 'org.hyperledger.fabric_samples.ABstore' } } task getDeps(type: Copy) { from sourceSets.main.compileClasspath into 'libs/' } Step 3: Download dependencies and build the project locally Run gradle build and gradle getDeps as shown in the following examples to build the chaincode locally and download dependencies. When the gradle getDeps task runs, Gradle creates the lib sub-directory on the client machine and downloads dependencies to it. 1. Download chaincode project dependencies locally. gradle getDeps The command creates output similar to the following example. Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.5/userguide/ command_line_interface.html#sec:command_line_warnings BUILD SUCCESSFUL in 1s 1 actionable task: 1 executed 2. Verify that dependencies were downloaded to the libs sub-directory. ls libs/ bcpkix-jdk15on-1.62.jar error_prone_annotations-2.3.4.jar grpc-protobuf- lite-1.31.1.jar jsr305-3.0.2.jar Develop Java Chaincode 118 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide bcprov-jdk15on-1.62.jar fabric-chaincode-protos-2.2.1.jar grpc- stub-1.31.1.jar listenablefuture-9999.0-empty-to-avoid-conflict-with- guava.jar checker-compat-qual-2.5.5.jar fabric-chaincode-shim-2.2.1.jar gson-2.8.6.jar org.everit.json.schema-1.12.1.jar classgraph-4.8.47.jar failureaccess-1.0.1.jar guava-29.0- android.jar protobuf-java-3.12.0.jar commons-cli-1.4.jar grpc-api-1.31.1.jar handy-uri- templates-2.1.8.jar protobuf-java-util-3.11.1.jar commons-collections-3.2.2.jar grpc-context-1.31.1.jar j2objc- annotations-1.3.jar proto-google-common-protos-1.17.0.jar commons-digester-1.8.1.jar grpc-core-1.31.1.jar javax.annotation- api-1.3.2.jar re2j-1.3.jar commons-logging-1.2.jar grpc-netty-shaded-1.31.1.jar joda- time-2.10.2.jar commons-validator-1.6.jar grpc-protobuf-1.31.1.jar json-20190722.jar 3. Build the project using Gradle. gradle build The command creates output similar to the following example. > Task :compileJava Note: /home/ec2-user/fabric-samples/chaincode/abstore/java/src/main/java/org/ hyperledger/fabric-samples/ABstore.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. BUILD SUCCESSFUL in 5s Step 4: Add dependencies downloaded in the previous step to the project Use a text editor to update the build.gradle file again so that it reference the dependencies in the libs sub-directory. This adds the dependencies that you downloaded in the previous step to the project. The following example shows an excerpt from a build.gradle file with relevant sections emphasized. buildscript { dependencies { Develop Java Chaincode 119 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide classpath fileTree(dir: 'plugin', include:['*.jar']) } } plugins { id 'java' } group 'org.hyperledger.fabric-chaincode-java' version '1.0-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenLocal() mavenCentral() } dependencies { compile fileTree(dir:'libs',includes:['*.jar']) testCompile group: 'junit', name: 'junit', version: '4.12' } apply plugin: 'com.github.johnrengelman.shadow' shadowJar { baseName = 'chaincode' version = null classifier = null manifest { attributes 'Main-Class': 'org.hyperledger.fabric_samples.ABstore' } } task getDeps(type: Copy) { from sourceSets.main.compileClasspath into 'libs/' } Develop Java Chaincode 120 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Step 5: Use the Hyperledger Fabric CLI to install the chaincode on the peer node Use the Hyperledger Fabric CLI to package the Java chaincode project and copy it to the peer node. The -l java option is required for the package command to specify that the chaincode is Java- based. The path to the Java chaincode working directory is an absolute path, which is different from chaincode written in golang. 1. Before running the following chaincode commands, establish variables for the Hyperledger Fabric CLI Docker container as shown in the following example. Alternatively, you can configure a Docker compose file to establish these variables. For more information, see Step 4.4: Configure and Run Docker Compose to Start the Hyperledger Fabric CLI in the getting started tutorial. Replace the values with those appropriate for your network. Set CORE_PEER_ADDRESS to the endpoint of the peer node for which you want to install the chaincode, set CORE_PEER_LOCALMSPID to the ID of |
amazon-managed-blockchain-hyperledger-fabric-dev-043 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 43 | is an absolute path, which is different from chaincode written in golang. 1. Before running the following chaincode commands, establish variables for the Hyperledger Fabric CLI Docker container as shown in the following example. Alternatively, you can configure a Docker compose file to establish these variables. For more information, see Step 4.4: Configure and Run Docker Compose to Start the Hyperledger Fabric CLI in the getting started tutorial. Replace the values with those appropriate for your network. Set CORE_PEER_ADDRESS to the endpoint of the peer node for which you want to install the chaincode, set CORE_PEER_LOCALMSPID to the ID of the member that owns the peer node, and set CORE_PEER_MSPCONFIGPATH as shown, which is the location of the membership service provider directory on the peer node. docker exec -e "CORE_PEER_TLS_ENABLED=true" \ -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem " \ -e "CORE_PEER_ADDRESS=nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y.m-K46ICRRXJRCGRNNS4ES4XUUS5A.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.us-east-1.amazonaws.com:30003" \ -e "CORE_PEER_LOCALMSPID=m-K46ICRRXJRCGRNNS4ES4XUUS5A" \ -e "CORE_PEER_MSPCONFIGPATH=/opt/home/admin-msp" 2. Running the Hyperledger Fabric CLI package command on the client packages the chaincode and writes the package to a file. The following example demonstrates a package command using the following flags: • The -p flag specifies the location of the chaincode on the client machine. When installing Java chaincode, this must be an absolute path. • The -l flag specifies that the chaincode language is java. • The --label flag specifies the package label, which is a human-readable description of the package. For more information about options, see peer lifecycle chaincode package in Hyperledger Fabric documentation. cli peer lifecycle chaincode package ./abstorejava.tar.gz \ -p /opt/home/fabric-samples/chaincode/abstore/java/ \ Develop Java Chaincode 121 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide -l java \ --label MyLabel 3. The following example installs the chaincode package on the peer node. cli peer lifecycle chaincode install abstorejava.tar.gz 4. The following example queries the installed chaincodes on the peer node. cli peer lifecycle chaincode queryinstalled 5. Running the Hyperledger Fabric CLI approveformyorg command on the client approves the chaincode definition for your organization. The following example demonstrates an approveformyorg command. • The -o flag specifies the ordering service endpoint for the member. • The --tls flag specifies that communication with the ordering service uses TLS. • The --cafile flag specifies the location of the certificate for the ordering service that you copied when you set up the Hyperledger Fabric admin. For more information, see step 5.1 in the Getting Started tutorial. • The -C flag specifies the channel on which to approve the chaincode. • The -n and -v options establish the name and version of the chaincode. • The --sequence flag specifies the sequence number of the chaincode definition for the channel. • The --package-id flag specifies the identifier of the chaincode install package. This value is returned by the queryinstalled command in the previous step. For more information about options, see peer lifecycle chaincode approveformyorg in Hyperledger Fabric documentation. cli peer lifecycle chaincode approveformyorg \ -o orderer.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 \ --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ -C MyHLFChannelID -n MyJavaChaincodeName -v MyCCVerNumber --sequence MySeqNumber -- package-id MyPackageID 6. The following example checks whether the chaincode definition is ready to be committed on the channel. Develop Java Chaincode 122 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide cli peer lifecycle chaincode checkcommitreadiness \ -o orderer.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 \ --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ -C MyHLFChannelID -n MyJavaChaincodeName -v MyCCVerNumber --sequence MySeqNumber 7. The following example commits the chaincode definition on the channel. cli peer lifecycle chaincode commit \ -o orderer.n- MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 \ --tls --cafile /opt/home/managedblockchain-tls-chain.pem \ -C MyHLFChannelID -n MyJavaChaincodeName -v MyCCVerNumber --sequence MySeqNumber 8. The following example queries the committed chaincode definitions by channel on the peer node. cli peer lifecycle chaincode querycommitted \ -C MyHLFChannelID Step 6: Invoke the sample chaincode to perform a transaction Precede the following example command with the variable overrides for the CLI container as shown in the previous example. The following example invokes the sample chaincode. The parameters are the same as the previous example, except for the JSON constructor. This constructor invokes the the sample chaincode to transfer a value of 10 from a to b. cli peer chaincode invoke \ -o orderer.n-MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 \ --cafile /opt/home/managedblockchain-tls-chain.pem --tls \ -C one-org-channel-java \ -c '{"Args":["invoke","a", "b", "10"]}' -n javacc The command should print output similar to the following. Develop Java Chaincode 123 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide 2020-06-26 23:49:43.895 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 003 Chaincode invoke successful. result: status:200 message:"invoke finished successfully" payload:"a: 90 b: 210 Step 7: Invoke the sample chaincode to query Precede the following command with the variable overrides for the CLI container as shown in the previous example. The following example queries the ledger for the value attributed to a. The query should print 90 as output. cli peer chaincode query \ -o orderer.n-MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 \ --cafile /opt/home/managedblockchain-tls-chain.pem --tls \ -C one-org-channel-java \ -c '{"Args":["query","a"]}' -n javacc Develop Java Chaincode 124 Amazon Managed |
amazon-managed-blockchain-hyperledger-fabric-dev-044 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 44 | Chaincode 123 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide 2020-06-26 23:49:43.895 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 003 Chaincode invoke successful. result: status:200 message:"invoke finished successfully" payload:"a: 90 b: 210 Step 7: Invoke the sample chaincode to query Precede the following command with the variable overrides for the CLI container as shown in the previous example. The following example queries the ledger for the value attributed to a. The query should print 90 as output. cli peer chaincode query \ -o orderer.n-MWY63ZJZU5HGNCMBQER7IN6OIU.managedblockchain.MyRegion.amazonaws.com:30001 \ --cafile /opt/home/managedblockchain-tls-chain.pem --tls \ -C one-org-channel-java \ -c '{"Args":["query","a"]}' -n javacc Develop Java Chaincode 124 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Amazon Managed Blockchain (AMB) API Reference for AMB Access Hyperledger Fabric Amazon Managed Blockchain (AMB) provides API operations for creating and managing networks, peer nodes, invitations, members, and proposals for AMB Access Hyperledger Fabric. For more information, see the AMB Access API Reference Guide . 125 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Amazon Managed Blockchain (AMB) Hyperledger Fabric Security Amazon Managed Blockchain (AMB) utilizes AWS features and the features of the open-source framework running on AMB Access to provide data protection as well as authentication and access control. This chapter covers security information specific to AMB Access Hyperledger Fabric. For security information specific to AMB Access Ethereum, see AMB Access Ethereum Security in the Amazon Managed Blockchain (AMB) Access Ethereum Developer Guide. Topics • Data Protection for Amazon Managed Blockchain (AMB) Hyperledger Fabric • Authentication and Access Control for AMB Access Hyperledger Fabric • Configuring Security Groups for Amazon Managed Blockchain (AMB) Hyperledger Fabric Data Protection for Amazon Managed Blockchain (AMB) Hyperledger Fabric The AWS shared responsibility model applies to data protection in Amazon Managed Blockchain (AMB) Hyperledger Fabric. As described in this model, AWS is responsible for protecting the global infrastructure that runs all of the AWS Cloud. You are responsible for maintaining control over your content that is hosted on this infrastructure. You are also responsible for the security configuration and management tasks for the AWS services that you use. For more information about data privacy, see the Data Privacy FAQ. For information about data protection in Europe, see the AWS Shared Responsibility Model and GDPR blog post on the AWS Security Blog. For data protection purposes, we recommend that you protect AWS account credentials and set up individual users with AWS IAM Identity Center or AWS Identity and Access Management (IAM). That way, each user is given only the permissions necessary to fulfill their job duties. We also recommend that you secure your data in the following ways: • Use multi-factor authentication (MFA) with each account. • Use SSL/TLS to communicate with AWS resources. We require TLS 1.2 and recommend TLS 1.3. Data Protection 126 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Set up API and user activity logging with AWS CloudTrail. For information about using CloudTrail trails to capture AWS activities, see Working with CloudTrail trails in the AWS CloudTrail User Guide. • Use AWS encryption solutions, along with all default security controls within AWS services. • Use advanced managed security services such as Amazon Macie, which assists in discovering and securing sensitive data that is stored in Amazon S3. • If you require FIPS 140-3 validated cryptographic modules when accessing AWS through a command line interface or an API, use a FIPS endpoint. For more information about the available FIPS endpoints, see Federal Information Processing Standard (FIPS) 140-3. We strongly recommend that you never put confidential or sensitive information, such as your customers' email addresses, into tags or free-form text fields such as a Name field. This includes when you work with AMB Access Hyperledger Fabric or other AWS services using the console, API, AWS CLI, or AWS SDKs. Any data that you enter into tags or free-form text fields used for names may be used for billing or diagnostic logs. If you provide a URL to an external server, we strongly recommend that you do not include credentials information in the URL to validate your request to that server. Data Encryption for AMB Access Hyperledger Fabric Data encryption helps prevent unauthorized users from reading data from a blockchain network and the associated data storage systems. This includes data saved to persistent media, known as data at rest, andtr data that may be intercepted as it travels the network, known as data in transit. Topics • Encryption at Rest for AMB Access Hyperledger Fabric • Encryption in Transit for AMB Access Hyperledger Fabric Encryption at Rest for AMB Access Hyperledger Fabric Amazon Managed Blockchain (AMB) offers fully managed encryption at rest. AMB Access encryption at rest provides enhanced security by encrypting all data at rest on networks, members, and peer nodes using keys in AWS Key Management Service (AWS KMS). This functionality helps reduce the |
amazon-managed-blockchain-hyperledger-fabric-dev-045 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 45 | systems. This includes data saved to persistent media, known as data at rest, andtr data that may be intercepted as it travels the network, known as data in transit. Topics • Encryption at Rest for AMB Access Hyperledger Fabric • Encryption in Transit for AMB Access Hyperledger Fabric Encryption at Rest for AMB Access Hyperledger Fabric Amazon Managed Blockchain (AMB) offers fully managed encryption at rest. AMB Access encryption at rest provides enhanced security by encrypting all data at rest on networks, members, and peer nodes using keys in AWS Key Management Service (AWS KMS). This functionality helps reduce the operational burden and complexity involved in protecting sensitive data. With encryption at rest, you can build security-sensitive blockchain applications that meet strict encryption compliance and regulatory requirements. Data Encryption 127 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Encryption at rest integrates with AWS KMS for managing the encryption key that is used to protect your Hyperledger Fabric data. For more information about AWS KMS, see AWS Key Management Service concepts in the AWS Key Management Service Developer Guide. In AMB Access Hyperledger Fabric, you can specify the type of AWS KMS key at the member level. This encryption key is then inherited by any peer nodes that the member creates. Data at the network level is encrypted using AWS owned keys by default at no additional cost. When you create a new member, you can choose one of the following types of KMS keys to protect your member and its peer nodes: • AWS owned key – The default encryption type, if no KMS key ARN is specified. The key is owned by AMB Access (no additional charge, and no configuration required). • Customer managed key – The key is stored in your AWS account and is created, owned, and managed by you. You have full control over the key (AWS KMS charges apply). When you access networks, members, and peer nodes, AMB Access decrypts the data transparently. You don't have to change any code or applications to use or manage encrypted data. All AMB Access operations work seamlessly on your encrypted data. You can specify a KMS key when you create a new member by using the AWS Management Console, the AMB Access API, or the AWS Command Line Interface (AWS CLI). For more information, see the MemberConfiguration data type in the Amazon Managed Blockchain (AMB) API Reference. You can pass this data type as an input parameter to the CreateMember or CreateNetwork API operations. Note By default, Amazon Managed Blockchain (AMB) automatically enables encryption at rest using AWS owned keys at no additional charge. However, AWS KMS charges apply for using a customer managed key. For information about pricing, see AWS Key Management Service pricing. Topics • Encryption at Rest: How It Works • How AMB Access Uses Grants in AWS KMS Encryption at Rest 128 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Encryption at Rest Considerations • Using Customer Managed Keys in AMB Access Encryption at Rest: How It Works AMB Access Hyperledger Fabric encryption at rest encrypts your data using 256-bit Advanced Encryption Standard (AES-256), which helps secure your data from unauthorized access to the underlying storage. Encryption at rest integrates with AWS Key Management Service (AWS KMS) for managing the encryption key that is used to protect your Hyperledger Fabric data. When creating a new member, you can choose one of the following types of AWS KMS keys: • AWS owned key • Customer managed key AWS owned key AWS owned keys aren't stored in your AWS account. They are part of a collection of KMS keys that AWS owns and manages for use in multiple AWS accounts. AWS services can use AWS owned keys to protect your data. You don't need to create or manage AWS owned keys. However, you can't view, use, track, or audit them. You aren't charged a monthly fee or a usage fee for AWS owned keys, and they don't count against the AWS KMS quotas for your account. For more information, see AWS owned keys in the AWS Key Management Service Developer Guide. Customer managed key Customer managed keys are KMS keys in your AWS account that you create, own, and manage. You have full control over these KMS keys. AMB Access supports symmetric customer managed keys only. Use a customer managed key to get the following features: • Setting and maintaining key policies, IAM policies, and grants to control access to the key • Enabling and disabling the key Encryption at Rest 129 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Rotating cryptographic material for the key • Creating key tags and aliases • Scheduling the key for deletion • Importing your own key material or using a custom key store that you own |
amazon-managed-blockchain-hyperledger-fabric-dev-046 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 46 | that you create, own, and manage. You have full control over these KMS keys. AMB Access supports symmetric customer managed keys only. Use a customer managed key to get the following features: • Setting and maintaining key policies, IAM policies, and grants to control access to the key • Enabling and disabling the key Encryption at Rest 129 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Rotating cryptographic material for the key • Creating key tags and aliases • Scheduling the key for deletion • Importing your own key material or using a custom key store that you own and manage • Using AWS CloudTrail and Amazon CloudWatch Logs to track the requests that AMB Access sends to AWS KMS on your behalf For more information, see Customer managed keys in the AWS Key Management Service Developer Guide. Customer managed keys incur a charge for each API call, and AWS KMS quotas apply to these KMS keys. For more information, see AWS KMS resource or request quotas. When you specify a customer managed key as the member-level KMS key, the member and its peer nodes are protected with the same customer managed key. Network-level data is encrypted using AWS owned keys by default at no additional cost. Inaccessible Customer Managed Keys If you disable your customer managed key, schedule the key for deletion, or revoke the grants on the key, the status of your member and its peer nodes becomes INACCESSIBLE_ENCRYPTION_KEY. In this state, the member and its peer nodes are impaired and might not function as expected. An inaccessible key prevents all users and the AMB Access service from encrypting or decrypting data—and from performing read and write operations on the nodes. AMB Access must have access to your KMS key to ensure that you can continue to access your nodes and to prevent data loss. The effect of disabling or deleting a key or of revoking a grant is not immediate. It might take some time for the member and peer node resources to discover that the key is inaccessible. When a resource is in this state, we recommend deleting and recreating the resource, and reconfiguring the KMS key. To check the encryption status of a member or peer node resource, use the GetMember or GetNode API operation respectively. How AMB Access Uses Grants in AWS KMS AMB Access requires grants to use your customer managed key. When you create a member that is protected with a customer managed key, AMB Access creates grants on your behalf by sending Encryption at Rest 130 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide CreateGrant requests to AWS KMS. Grants in AWS KMS are used to give AMB Access access to a KMS key in a customer AWS account. For more information, see Using Grants in the AWS Key Management Service Developer Guide. AMB Access requires the grants to use your customer managed key for the following API operations: • Decrypt • DescribeKey • Encrypt • GenerateDataKey • GenerateDataKeyWithoutPlaintext • ReEncryptFrom • ReEncryptTo AMB Access uses Amazon Elastic Compute Cloud (Amazon EC2), Amazon Elastic Block Store (Amazon EBS), and AWS Secrets Manager to call these AWS KMS operations on its behalf. You can revoke a grant to remove the service's access to the customer managed key at any time. If you do, the key becomes inaccessible, and AMB Access loses access to any of the data protected by the customer managed key. In this state, the member and its peer node resources are impaired and might not function as expected. When a resource is in this state, we recommend deleting and recreating the resource, and reconfiguring the KMS key. Encryption at Rest Considerations Consider the following when you are using encryption at rest in AMB Access Hyperledger Fabric. • Server-side encryption at rest is enabled on all AMB Access network, member, and peer node data and can't be disabled. You can't encrypt only a subset of data in these resource types. • Encryption at rest only encrypts data while it is static (at rest) on a persistent storage media. If data security is a concern for data in transit or data in use, you might need to take additional measures as follows: • Data in transit: All your data in AMB Access is encrypted in transit. By default, communications to and from AMB Access use the HTTPS protocol, which protects network traffic by using Secure Sockets Layer (SSL)/Transport Layer Security (TLS) encryption. Encryption at Rest 131 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Data in use: Use client-side encryption to protect your data before sending it to AMB Access. • AMB Access currently doesn't support encryption context for AWS KMS cryptographic operations. Using Customer Managed Keys in AMB Access You can use the AMB Access console, the AMB |
amazon-managed-blockchain-hyperledger-fabric-dev-047 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 47 | as follows: • Data in transit: All your data in AMB Access is encrypted in transit. By default, communications to and from AMB Access use the HTTPS protocol, which protects network traffic by using Secure Sockets Layer (SSL)/Transport Layer Security (TLS) encryption. Encryption at Rest 131 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Data in use: Use client-side encryption to protect your data before sending it to AMB Access. • AMB Access currently doesn't support encryption context for AWS KMS cryptographic operations. Using Customer Managed Keys in AMB Access You can use the AMB Access console, the AMB Access API, or the AWS CLI to specify the AWS KMS key for new members in AMB Access. The following topics describe how to manage and monitor the usage of your customer managed keys in AMB Access. Topics • Prerequisites • Specifying a Customer Managed Key • Monitoring Your Customer Managed Keys Prerequisites Before you can protect AMB Access resources with a customer managed key, you must first create the key in AWS KMS. You must also specify a key policy that allows AMB Access to create grants on that AWS KMS key on your behalf. Creating a Customer Managed Key To create a customer managed key, follow the steps in Creating symmetric encryption KMS keys in the AWS Key Management Service Developer Guide. AMB Access doesn't support asymmetric keys. Setting a Key Policy Key policies are the primary way to control access to customer managed keys in AWS KMS. Every customer managed key must have exactly one key policy. The statements in the key policy document determine who has permission to use the AWS KMS key and how they can use it. For more information, see Using key policies in AWS KMS in the AWS Key Management Service Developer Guide. You can specify a key policy when you create your customer managed key. To change a key policy for an existing customer managed key, see Changing a key policy. To allow AMB Access to use your customer managed key, the key policy must include permissions for the CreateGrant API operation. This operation adds a grant to a customer Encryption at Rest 132 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide managed key. Grants control access to a specified KMS key. AMB Access creates grants that allow access to the grant operations that it requires, which are listed in How AMB Access Uses Grants in AWS KMS. Key Policy Example The following is a key policy example that you can use for AMB Access. This policy allows principals that are authorized to use AMB Access from the account 111122223333 to call the CreateGrant operation on all resources. To use this policy, replace aws-region and 111122223333 in the example with your own information. { "Version": "2012-10-17", "Statement": [ { "Sid" : "AllowAccessToUseAMB", "Effect" : "Allow", "Principal" : { "AWS" : "*" }, "Action" : [ "kms:CreateGrant" ], "Resource" : "*", "Condition" : { "StringEquals" : { "kms:ViaService" : "managedblockchain.aws-region.amazonaws.com", "kms:CallerAccount" : "111122223333" } } } ] } Specifying a Customer Managed Key You can specify the Amazon Resource Name (ARN) of a customer managed KMS key when you create a new member by using the AMB Access console, the AMB Access API, or the AWS CLI. The following is an example of a KMS key ARN. Encryption at Rest 133 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab For more information, see the MemberConfiguration data type in the Amazon Managed Blockchain (AMB) API Reference. You can pass this data type as an input parameter to the CreateMember or CreateNetwork API operations. Monitoring Your Customer Managed Keys If you use a customer managed key to protect your Amazon Managed Blockchain (AMB) resources, you can use AWS CloudTrail or Amazon CloudWatch Logs to track the requests that AMB Access sends to AWS KMS on your behalf. For more information, see Monitoring AWS KMS keys in the AWS Key Management Service Developer Guide. The following example is a CloudTrail log entry for the CreateGrant API operation. In addition to this event from AMB Access, you can expect AWS KMS calls for your customer managed key from Amazon EC2, Amazon EBS, and AWS Secrets Manager. These AWS services call other AWS KMS operations such as GenerateDataKey, Decrypt, and Encrypt on behalf of AMB Access. CreateGrant When you specify a customer managed key to protect your member, AMB Access sends CreateGrant requests to AWS KMS on your behalf to allow access to your KMS key. The grants that AMB Access creates are specific to a member and its peer nodes. The principal in the CreateGrant request is the user who created the member or peer node. The event that records the CreateGrant operation is similar to the following example event. The parameters include the Amazon |
amazon-managed-blockchain-hyperledger-fabric-dev-048 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 48 | Manager. These AWS services call other AWS KMS operations such as GenerateDataKey, Decrypt, and Encrypt on behalf of AMB Access. CreateGrant When you specify a customer managed key to protect your member, AMB Access sends CreateGrant requests to AWS KMS on your behalf to allow access to your KMS key. The grants that AMB Access creates are specific to a member and its peer nodes. The principal in the CreateGrant request is the user who created the member or peer node. The event that records the CreateGrant operation is similar to the following example event. The parameters include the Amazon Resource Name (ARN) of the customer managed key, the grantee principal and retiring principal (the AMB Access service), and the operations that the grant covers. { "eventVersion": "1.08", "userIdentity": { "type": "IAMUser", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::111122223333:user/sample-user", "accountId": "111122223333", "accessKeyId": "AKIAI44QH8DHBEXAMPLE", "userName": "sample-user", "sessionContext": { Encryption at Rest 134 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "sessionIssuer": {}, "webIdFederationData": {}, "attributes": { "mfaAuthenticated": "false", "creationDate": "2021-06-08T16:36:03Z" } }, "invokedBy": "managedblockchain.amazonaws.com" }, "eventTime": "2021-06-08T16:36:04Z", "eventSource": "kms.amazonaws.com", "eventName": "CreateGrant", "awsRegion": "us-east-1", "sourceIPAddress": "managedblockchain.amazonaws.com", "userAgent": "managedblockchain.amazonaws.com", "requestParameters": { "keyId": "arn:aws:kms:us- east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab", "granteePrincipal": "managedblockchain.us-east-1.amazonaws.com", "retiringPrincipal": "managedblockchain.us-east-1.amazonaws.com", "operations": [ "Decrypt" ], "constraints": { "encryptionContextSubset": {} } }, "responseElements": { "grantId": "64690d7d6ad23d39edd0c8fdea6400f297fae673ad84ce3563b6ca3a1e685ba2" }, "requestID": "55b9f158-f537-43c2-acec-f336f41866b1", "eventID": "944aa59c-3bf9-4092-9ca2-435f585b41f6", "readOnly": false, "resources": [ { "accountId": "111122223333", "type": "AWS::KMS::Key", "ARN": "arn:aws:kms:us- east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab" } ], "eventType": "AwsApiCall", "managementEvent": true, Encryption at Rest 135 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "eventCategory": "Management", "recipientAccountId": "111122223333" } Encryption in Transit for AMB Access Hyperledger Fabric The Hyperledger Fabric certificate authority (CA) in each membership provides a TLS certificate authority to secure Hyperledger Fabric communication channels in the Amazon Managed Blockchain (AMB) network. For more information, see the Fabric CA's User Guide in Hyperledger Fabric documentation. Authentication and Access Control for AMB Access Hyperledger Fabric AWS Identity and Access Management (IAM) permissions policies, VPC endpoint services powered by AWS PrivateLink, and Amazon EC2 security groups provide the primary means for you to control access to Amazon Managed Blockchain (AMB). In addition to these AWS services, open-source frameworks that run on AMB Access have authentication and access control features that you can configure. IAM permissions policies are associated with AWS users in your account and determine who has access to what. Permissions policies specify the actions that each user can perform using AMB Access and other AWS services. VPC endpoint services allow each AMB Access network member to connect privately to AMB Access resources. Amazon EC2 security groups act as virtual firewalls and determine the inbound and outbound network traffic that is allowed between AMB Access resources and other Amazon EC2 resources. In AMB Access, these security groups are associated with the VPC endpoint in your account and with any framework clients that run on AWS, such as a Hyperledger Fabric client running on an Amazon EC2 instance. Before you configure authentication and access control using AWS services and open-source features, we recommend that you review the following resources: • For more information about IAM and IAM permissions policies, see Identity and Access Management for Amazon Managed Blockchain (AMB) Hyperledger Fabric. We also recommend What is IAM? and IAM JSON Policy Reference in the IAM User Guide. Encryption in Transit 136 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • For more information about VPC endpoints, see Create an Interface VPC Endpoint for Amazon Managed Blockchain (AMB) Hyperledger Fabric and VPC Endpoints in the Amazon VPC User Guide. • For more information about Amazon EC2 security groups, see Configuring Security Groups for Amazon Managed Blockchain (AMB) Hyperledger Fabric and Amazon EC2 Security Groups for Linux Instances in the Amazon EC2 User Guide. • For more information about the Hyperledger Fabric Certificate Authority (CA), see Certificate Authority (CA) Setup in the Hyperledger Fabric documentation. • For more information about the supported Hyperledger Fabric 2.2 application access control lists, see Application Access Control Lists in the Hyperledger Fabric documentation. Identity and Access Management for Amazon Managed Blockchain (AMB) Hyperledger Fabric AWS Identity and Access Management (IAM) is an AWS service that helps an administrator securely control access to AWS resources. IAM administrators control who can be authenticated (signed in) and authorized (have permissions) to use AMB Access Hyperledger Fabric resources. IAM is an AWS service that you can use with no additional charge. Topics • Audience • Authenticating with identities • Managing access using policies • How Amazon Managed Blockchain (AMB) Hyperledger Fabric works with IAM • Troubleshooting Amazon Managed Blockchain (AMB) Hyperledger Fabric identity and access • Amazon Managed Blockchain (AMB) Hyperledger Fabric Identity-Based Policy Examples • Example IAM Role Permissions Policy for Hyperledger Fabric Client EC2 Instance • Using Service-Linked Roles for AMB Access Audience How you use AWS Identity and Access Management (IAM) differs, depending on the work that you do in |
amazon-managed-blockchain-hyperledger-fabric-dev-049 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 49 | AMB Access Hyperledger Fabric resources. IAM is an AWS service that you can use with no additional charge. Topics • Audience • Authenticating with identities • Managing access using policies • How Amazon Managed Blockchain (AMB) Hyperledger Fabric works with IAM • Troubleshooting Amazon Managed Blockchain (AMB) Hyperledger Fabric identity and access • Amazon Managed Blockchain (AMB) Hyperledger Fabric Identity-Based Policy Examples • Example IAM Role Permissions Policy for Hyperledger Fabric Client EC2 Instance • Using Service-Linked Roles for AMB Access Audience How you use AWS Identity and Access Management (IAM) differs, depending on the work that you do in AMB Access Hyperledger Fabric. Identity and Access Management 137 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Service user – If you use the AMB Access Hyperledger Fabric service to do your job, then your administrator provides you with the credentials and permissions that you need. As you use more AMB Access Hyperledger Fabric features to do your work, you might need additional permissions. Understanding how access is managed can help you request the right permissions from your administrator. If you cannot access a feature in AMB Access Hyperledger Fabric, see Troubleshooting Amazon Managed Blockchain (AMB) Hyperledger Fabric identity and access. Service administrator – If you're in charge of AMB Access Hyperledger Fabric resources at your company, you probably have full access to AMB Access Hyperledger Fabric. It's your job to determine which AMB Access Hyperledger Fabric features and resources your service users should access. You must then submit requests to your IAM administrator to change the permissions of your service users. Review the information on this page to understand the basic concepts of IAM. To learn more about how your company can use IAM with AMB Access Hyperledger Fabric, see How Amazon Managed Blockchain (AMB) Hyperledger Fabric works with IAM. IAM administrator – If you're an IAM administrator, you might want to learn details about how you can write policies to manage access to AMB Access Hyperledger Fabric. To view example AMB Access Hyperledger Fabric identity-based policies that you can use in IAM, see Amazon Managed Blockchain (AMB) Hyperledger Fabric Identity-Based Policy Examples. Authenticating with identities Authentication is how you sign in to AWS using your identity credentials. You must be authenticated (signed in to AWS) as the AWS account root user, as an IAM user, or by assuming an IAM role. You can sign in to AWS as a federated identity by using credentials provided through an identity source. AWS IAM Identity Center (IAM Identity Center) users, your company's single sign-on authentication, and your Google or Facebook credentials are examples of federated identities. When you sign in as a federated identity, your administrator previously set up identity federation using IAM roles. When you access AWS by using federation, you are indirectly assuming a role. Depending on the type of user you are, you can sign in to the AWS Management Console or the AWS access portal. For more information about signing in to AWS, see How to sign in to your AWS account in the AWS Sign-In User Guide. If you access AWS programmatically, AWS provides a software development kit (SDK) and a command line interface (CLI) to cryptographically sign your requests by using your credentials. If you don't use AWS tools, you must sign requests yourself. For more information about using the Identity and Access Management 138 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide recommended method to sign requests yourself, see AWS Signature Version 4 for API requests in the IAM User Guide. Regardless of the authentication method that you use, you might be required to provide additional security information. For example, AWS recommends that you use multi-factor authentication (MFA) to increase the security of your account. To learn more, see Multi-factor authentication in the AWS IAM Identity Center User Guide and AWS Multi-factor authentication in IAM in the IAM User Guide. AWS account root user When you create an AWS account, you begin with one sign-in identity that has complete access to all AWS services and resources in the account. This identity is called the AWS account root user and is accessed by signing in with the email address and password that you used to create the account. We strongly recommend that you don't use the root user for your everyday tasks. Safeguard your root user credentials and use them to perform the tasks that only the root user can perform. For the complete list of tasks that require you to sign in as the root user, see Tasks that require root user credentials in the IAM User Guide. Federated identity As a best practice, require human users, including users that require administrator access, to use federation with an identity provider to access AWS services by using temporary credentials. A federated identity is a user |
amazon-managed-blockchain-hyperledger-fabric-dev-050 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 50 | create the account. We strongly recommend that you don't use the root user for your everyday tasks. Safeguard your root user credentials and use them to perform the tasks that only the root user can perform. For the complete list of tasks that require you to sign in as the root user, see Tasks that require root user credentials in the IAM User Guide. Federated identity As a best practice, require human users, including users that require administrator access, to use federation with an identity provider to access AWS services by using temporary credentials. A federated identity is a user from your enterprise user directory, a web identity provider, the AWS Directory Service, the Identity Center directory, or any user that accesses AWS services by using credentials provided through an identity source. When federated identities access AWS accounts, they assume roles, and the roles provide temporary credentials. For centralized access management, we recommend that you use AWS IAM Identity Center. You can create users and groups in IAM Identity Center, or you can connect and synchronize to a set of users and groups in your own identity source for use across all your AWS accounts and applications. For information about IAM Identity Center, see What is IAM Identity Center? in the AWS IAM Identity Center User Guide. IAM users and groups An IAM user is an identity within your AWS account that has specific permissions for a single person or application. Where possible, we recommend relying on temporary credentials instead of creating Identity and Access Management 139 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide IAM users who have long-term credentials such as passwords and access keys. However, if you have specific use cases that require long-term credentials with IAM users, we recommend that you rotate access keys. For more information, see Rotate access keys regularly for use cases that require long- term credentials in the IAM User Guide. An IAM group is an identity that specifies a collection of IAM users. You can't sign in as a group. You can use groups to specify permissions for multiple users at a time. Groups make permissions easier to manage for large sets of users. For example, you could have a group named IAMAdmins and give that group permissions to administer IAM resources. Users are different from roles. A user is uniquely associated with one person or application, but a role is intended to be assumable by anyone who needs it. Users have permanent long-term credentials, but roles provide temporary credentials. To learn more, see Use cases for IAM users in the IAM User Guide. IAM roles An IAM role is an identity within your AWS account that has specific permissions. It is similar to an IAM user, but is not associated with a specific person. To temporarily assume an IAM role in the AWS Management Console, you can switch from a user to an IAM role (console). You can assume a role by calling an AWS CLI or AWS API operation or by using a custom URL. For more information about methods for using roles, see Methods to assume a role in the IAM User Guide. IAM roles with temporary credentials are useful in the following situations: • Federated user access – To assign permissions to a federated identity, you create a role and define permissions for the role. When a federated identity authenticates, the identity is associated with the role and is granted the permissions that are defined by the role. For information about roles for federation, see Create a role for a third-party identity provider (federation) in the IAM User Guide. If you use IAM Identity Center, you configure a permission set. To control what your identities can access after they authenticate, IAM Identity Center correlates the permission set to a role in IAM. For information about permissions sets, see Permission sets in the AWS IAM Identity Center User Guide. • Temporary IAM user permissions – An IAM user or role can assume an IAM role to temporarily take on different permissions for a specific task. • Cross-account access – You can use an IAM role to allow someone (a trusted principal) in a different account to access resources in your account. Roles are the primary way to grant cross- account access. However, with some AWS services, you can attach a policy directly to a resource Identity and Access Management 140 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide (instead of using a role as a proxy). To learn the difference between roles and resource-based policies for cross-account access, see Cross account resource access in IAM in the IAM User Guide. • Cross-service access – Some AWS services use features in other AWS services. For example, when you make a call in a service, it's common for that service |
amazon-managed-blockchain-hyperledger-fabric-dev-051 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 51 | in your account. Roles are the primary way to grant cross- account access. However, with some AWS services, you can attach a policy directly to a resource Identity and Access Management 140 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide (instead of using a role as a proxy). To learn the difference between roles and resource-based policies for cross-account access, see Cross account resource access in IAM in the IAM User Guide. • Cross-service access – Some AWS services use features in other AWS services. For example, when you make a call in a service, it's common for that service to run applications in Amazon EC2 or store objects in Amazon S3. A service might do this using the calling principal's permissions, using a service role, or using a service-linked role. • Forward access sessions (FAS) – When you use an IAM user or role to perform actions in AWS, you are considered a principal. When you use some services, you might perform an action that then initiates another action in a different service. FAS uses the permissions of the principal calling an AWS service, combined with the requesting AWS service to make requests to downstream services. FAS requests are only made when a service receives a request that requires interactions with other AWS services or resources to complete. In this case, you must have permissions to perform both actions. For policy details when making FAS requests, see Forward access sessions. • Service role – A service role is an IAM role that a service assumes to perform actions on your behalf. An IAM administrator can create, modify, and delete a service role from within IAM. For more information, see Create a role to delegate permissions to an AWS service in the IAM User Guide. • Service-linked role – A service-linked role is a type of service role that is linked to an AWS service. The service can assume the role to perform an action on your behalf. Service-linked roles appear in your AWS account and are owned by the service. An IAM administrator can view, but not edit the permissions for service-linked roles. • Applications running on Amazon EC2 – You can use an IAM role to manage temporary credentials for applications that are running on an EC2 instance and making AWS CLI or AWS API requests. This is preferable to storing access keys within the EC2 instance. To assign an AWS role to an EC2 instance and make it available to all of its applications, you create an instance profile that is attached to the instance. An instance profile contains the role and enables programs that are running on the EC2 instance to get temporary credentials. For more information, see Use an IAM role to grant permissions to applications running on Amazon EC2 instances in the IAM User Guide. Managing access using policies You control access in AWS by creating policies and attaching them to AWS identities or resources. A policy is an object in AWS that, when associated with an identity or resource, defines their Identity and Access Management 141 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide permissions. AWS evaluates these policies when a principal (user, root user, or role session) makes a request. Permissions in the policies determine whether the request is allowed or denied. Most policies are stored in AWS as JSON documents. For more information about the structure and contents of JSON policy documents, see Overview of JSON policies in the IAM User Guide. Administrators can use AWS JSON policies to specify who has access to what. That is, which principal can perform actions on what resources, and under what conditions. By default, users and roles have no permissions. To grant users permission to perform actions on the resources that they need, an IAM administrator can create IAM policies. The administrator can then add the IAM policies to roles, and users can assume the roles. IAM policies define permissions for an action regardless of the method that you use to perform the operation. For example, suppose that you have a policy that allows the iam:GetRole action. A user with that policy can get role information from the AWS Management Console, the AWS CLI, or the AWS API. Identity-based policies Identity-based policies are JSON permissions policy documents that you can attach to an identity, such as an IAM user, group of users, or role. These policies control what actions users and roles can perform, on which resources, and under what conditions. To learn how to create an identity-based policy, see Define custom IAM permissions with customer managed policies in the IAM User Guide. Identity-based policies can be further categorized as inline policies or managed policies. Inline policies are embedded directly into a single user, group, or role. Managed policies are standalone policies that you |
amazon-managed-blockchain-hyperledger-fabric-dev-052 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 52 | or the AWS API. Identity-based policies Identity-based policies are JSON permissions policy documents that you can attach to an identity, such as an IAM user, group of users, or role. These policies control what actions users and roles can perform, on which resources, and under what conditions. To learn how to create an identity-based policy, see Define custom IAM permissions with customer managed policies in the IAM User Guide. Identity-based policies can be further categorized as inline policies or managed policies. Inline policies are embedded directly into a single user, group, or role. Managed policies are standalone policies that you can attach to multiple users, groups, and roles in your AWS account. Managed policies include AWS managed policies and customer managed policies. To learn how to choose between a managed policy or an inline policy, see Choose between managed policies and inline policies in the IAM User Guide. Resource-based policies Resource-based policies are JSON policy documents that you attach to a resource. Examples of resource-based policies are IAM role trust policies and Amazon S3 bucket policies. In services that support resource-based policies, service administrators can use them to control access to a specific resource. For the resource where the policy is attached, the policy defines what actions a specified principal can perform on that resource and under what conditions. You must specify a principal in a resource-based policy. Principals can include accounts, users, roles, federated users, or AWS services. Identity and Access Management 142 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Resource-based policies are inline policies that are located in that service. You can't use AWS managed policies from IAM in a resource-based policy. Access control lists (ACLs) Access control lists (ACLs) control which principals (account members, users, or roles) have permissions to access a resource. ACLs are similar to resource-based policies, although they do not use the JSON policy document format. Amazon S3, AWS WAF, and Amazon VPC are examples of services that support ACLs. To learn more about ACLs, see Access control list (ACL) overview in the Amazon Simple Storage Service Developer Guide. Other policy types AWS supports additional, less-common policy types. These policy types can set the maximum permissions granted to you by the more common policy types. • Permissions boundaries – A permissions boundary is an advanced feature in which you set the maximum permissions that an identity-based policy can grant to an IAM entity (IAM user or role). You can set a permissions boundary for an entity. The resulting permissions are the intersection of an entity's identity-based policies and its permissions boundaries. Resource-based policies that specify the user or role in the Principal field are not limited by the permissions boundary. An explicit deny in any of these policies overrides the allow. For more information about permissions boundaries, see Permissions boundaries for IAM entities in the IAM User Guide. • Service control policies (SCPs) – SCPs are JSON policies that specify the maximum permissions for an organization or organizational unit (OU) in AWS Organizations. AWS Organizations is a service for grouping and centrally managing multiple AWS accounts that your business owns. If you enable all features in an organization, then you can apply service control policies (SCPs) to any or all of your accounts. The SCP limits permissions for entities in member accounts, including each AWS account root user. For more information about Organizations and SCPs, see Service control policies in the AWS Organizations User Guide. • Resource control policies (RCPs) – RCPs are JSON policies that you can use to set the maximum available permissions for resources in your accounts without updating the IAM policies attached to each resource that you own. The RCP limits permissions for resources in member accounts and can impact the effective permissions for identities, including the AWS account root user, regardless of whether they belong to your organization. For more information about Organizations and RCPs, including a list of AWS services that support RCPs, see Resource control policies (RCPs) in the AWS Organizations User Guide. Identity and Access Management 143 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Session policies – Session policies are advanced policies that you pass as a parameter when you programmatically create a temporary session for a role or federated user. The resulting session's permissions are the intersection of the user or role's identity-based policies and the session policies. Permissions can also come from a resource-based policy. An explicit deny in any of these policies overrides the allow. For more information, see Session policies in the IAM User Guide. Multiple policy types When multiple types of policies apply to a request, the resulting permissions are more complicated to understand. To learn how AWS determines whether to allow a request when multiple policy types are involved, see Policy evaluation logic in the IAM User |
amazon-managed-blockchain-hyperledger-fabric-dev-053 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 53 | temporary session for a role or federated user. The resulting session's permissions are the intersection of the user or role's identity-based policies and the session policies. Permissions can also come from a resource-based policy. An explicit deny in any of these policies overrides the allow. For more information, see Session policies in the IAM User Guide. Multiple policy types When multiple types of policies apply to a request, the resulting permissions are more complicated to understand. To learn how AWS determines whether to allow a request when multiple policy types are involved, see Policy evaluation logic in the IAM User Guide. How Amazon Managed Blockchain (AMB) Hyperledger Fabric works with IAM Before you use IAM to manage access to AMB Access Hyperledger Fabric, learn what IAM features are available to use with AMB Access Hyperledger Fabric. IAM features you can use with Amazon Managed Blockchain (AMB) Hyperledger Fabric IAM feature AMB Access Hyperledger Fabric support Identity-based policies Resource-based policies Policy actions Policy resources Policy condition keys (service-specific) ACLs ABAC (tags in policies) Temporary credentials Principal permissions Service roles Yes No Yes Yes No No Yes Yes Yes Yes Identity and Access Management 144 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide IAM feature AMB Access Hyperledger Fabric support Service-linked roles Yes To get a high-level view of how AMB Access Hyperledger Fabric and other AWS services work with most IAM features, see AWS services that work with IAM in the IAM User Guide. Identity-based policies for AMB Access Hyperledger Fabric Supports identity-based policies: Yes Identity-based policies are JSON permissions policy documents that you can attach to an identity, such as an IAM user, group of users, or role. These policies control what actions users and roles can perform, on which resources, and under what conditions. To learn how to create an identity-based policy, see Define custom IAM permissions with customer managed policies in the IAM User Guide. With IAM identity-based policies, you can specify allowed or denied actions and resources as well as the conditions under which actions are allowed or denied. You can't specify the principal in an identity-based policy because it applies to the user or role to which it is attached. To learn about all of the elements that you can use in a JSON policy, see IAM JSON policy elements reference in the IAM User Guide. Identity-based policy examples for AMB Access Hyperledger Fabric To view examples of AMB Access Hyperledger Fabric identity-based policies, see Amazon Managed Blockchain (AMB) Hyperledger Fabric Identity-Based Policy Examples. Resource-based policies within AMB Access Hyperledger Fabric Supports resource-based policies: No Resource-based policies are JSON policy documents that you attach to a resource. Examples of resource-based policies are IAM role trust policies and Amazon S3 bucket policies. In services that support resource-based policies, service administrators can use them to control access to a specific resource. For the resource where the policy is attached, the policy defines what actions a specified principal can perform on that resource and under what conditions. You must specify a principal in a resource-based policy. Principals can include accounts, users, roles, federated users, or AWS services. Identity and Access Management 145 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide To enable cross-account access, you can specify an entire account or IAM entities in another account as the principal in a resource-based policy. Adding a cross-account principal to a resource- based policy is only half of establishing the trust relationship. When the principal and the resource are in different AWS accounts, an IAM administrator in the trusted account must also grant the principal entity (user or role) permission to access the resource. They grant permission by attaching an identity-based policy to the entity. However, if a resource-based policy grants access to a principal in the same account, no additional identity-based policy is required. For more information, see Cross account resource access in IAM in the IAM User Guide. Policy actions for AMB Access Hyperledger Fabric Supports policy actions: Yes Administrators can use AWS JSON policies to specify who has access to what. That is, which principal can perform actions on what resources, and under what conditions. The Action element of a JSON policy describes the actions that you can use to allow or deny access in a policy. Policy actions usually have the same name as the associated AWS API operation. There are some exceptions, such as permission-only actions that don't have a matching API operation. There are also some operations that require multiple actions in a policy. These additional actions are called dependent actions. Include actions in a policy to grant permissions to perform the associated operation. To see a list of AMB Access Hyperledger Fabric actions, see Actions defined by Amazon Managed Blockchain (AMB) Hyperledger Fabric in the Service Authorization Reference. Policy actions in AMB Access Hyperledger |
amazon-managed-blockchain-hyperledger-fabric-dev-054 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 54 | use to allow or deny access in a policy. Policy actions usually have the same name as the associated AWS API operation. There are some exceptions, such as permission-only actions that don't have a matching API operation. There are also some operations that require multiple actions in a policy. These additional actions are called dependent actions. Include actions in a policy to grant permissions to perform the associated operation. To see a list of AMB Access Hyperledger Fabric actions, see Actions defined by Amazon Managed Blockchain (AMB) Hyperledger Fabric in the Service Authorization Reference. Policy actions in AMB Access Hyperledger Fabric use the following prefix before the action: managedblockchain: For example, to grant someone permission to create a node with the AMB Access CreateNode API operation, you include the managedblockchain:CreateNode action in their policy. Policy statements must include either an Action or NotAction element. AMB Access Hyperledger Fabric defines its own set of actions that describe tasks that you can perform with this service. To specify multiple actions in a single statement, separate them with commas. "Action": [ Identity and Access Management 146 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "managedblockchain::action1", "managedblockchain::action2" ] You can specify multiple actions using wildcards (*). For example, to specify all actions that begin with the word Describe, include the following action: "Action": "managedblockchain::List*" To view examples of AMB Access Hyperledger Fabric identity-based policies, see Amazon Managed Blockchain (AMB) Hyperledger Fabric Identity-Based Policy Examples. Policy resources for AMB Access Hyperledger Fabric Supports policy resources: Yes Administrators can use AWS JSON policies to specify who has access to what. That is, which principal can perform actions on what resources, and under what conditions. The Resource JSON policy element specifies the object or objects to which the action applies. Statements must include either a Resource or a NotResource element. As a best practice, specify a resource using its Amazon Resource Name (ARN). You can do this for actions that support a specific resource type, known as resource-level permissions. For actions that don't support resource-level permissions, such as listing operations, use a wildcard (*) to indicate that the statement applies to all resources. "Resource": "*" AMB Access resource types that can be used in IAM permissions policy statements for resources on Ethereum networks include the following: • network • member • node • proposal • invitation Identity and Access Management 147 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Members, nodes, and invitations are associated with your account. Networks and proposals, on the other hand, are scoped to the entire blockchain network and are not associated with a particular account. For example a network resource on AMB Access has the following ARN. arn:${Partition}:managedblockchain:${Region}::networks/${NetworkId} For example, to specify the n-MWY63ZJZU5HGNCMBQER7IN6OIU network in your statement, use the following ARN. "Resource": "arn:aws:managedblockchain:us-east-1::networks/n- MWY63ZJZU5HGNCMBQER7IN6OIU" To specify any network that is visible to your account, use the wildcard (*). "Resource": "arn:aws:managedblockchain:us-east-1::networks/*" Some AMB Access Hyperledger Fabric actions, such as CreateNetwork, ListInvitations, and ListNetworks cannot be performed on a specific resource. In those cases, you must use the wildcard (*). "Resource": "*" To see a list of AMB Access Hyperledger Fabric resource types and their ARNs, see Resources defined by Amazon Managed Blockchain (AMB) Hyperledger Fabric in the Service Authorization Reference. To learn with which actions you can specify the ARN of each resource, see Actions defined by Amazon Managed Blockchain (AMB) Hyperledger Fabric. To view examples of AMB Access Hyperledger Fabric identity-based policies, see Amazon Managed Blockchain (AMB) Hyperledger Fabric Identity-Based Policy Examples. Policy condition keys for AMB Access Hyperledger Fabric Supports service-specific policy condition keys: No Administrators can use AWS JSON policies to specify who has access to what. That is, which principal can perform actions on what resources, and under what conditions. Identity and Access Management 148 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide The Condition element (or Condition block) lets you specify conditions in which a statement is in effect. The Condition element is optional. You can create conditional expressions that use condition operators, such as equals or less than, to match the condition in the policy with values in the request. If you specify multiple Condition elements in a statement, or multiple keys in a single Condition element, AWS evaluates them using a logical AND operation. If you specify multiple values for a single condition key, AWS evaluates the condition using a logical OR operation. All of the conditions must be met before the statement's permissions are granted. You can also use placeholder variables when you specify conditions. For example, you can grant an IAM user permission to access a resource only if it is tagged with their IAM user name. For more information, see IAM policy elements: variables and tags in the IAM User Guide. AWS supports global condition keys and service-specific condition keys. To see |
amazon-managed-blockchain-hyperledger-fabric-dev-055 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 55 | element, AWS evaluates them using a logical AND operation. If you specify multiple values for a single condition key, AWS evaluates the condition using a logical OR operation. All of the conditions must be met before the statement's permissions are granted. You can also use placeholder variables when you specify conditions. For example, you can grant an IAM user permission to access a resource only if it is tagged with their IAM user name. For more information, see IAM policy elements: variables and tags in the IAM User Guide. AWS supports global condition keys and service-specific condition keys. To see all AWS global condition keys, see AWS global condition context keys in the IAM User Guide. Note AMB Access Hyperledger Fabric does not provide any service-specific condition keys, but it does support using some AWS global condition keys. To see a list of the AWS global condition keys supported, see Condition keys for Amazon Managed Blockchain (AMB) Hyperledger Fabric in the Service Authorization Reference. To learn with which actions and resources you can use a condition key, see Actions defined by Amazon Managed Blockchain (AMB) Hyperledger Fabric. To view examples of AMB Access Hyperledger Fabric identity-based policies, see Amazon Managed Blockchain (AMB) Hyperledger Fabric Identity-Based Policy Examples. ACLs in AMB Access Hyperledger Fabric Supports ACLs: No Access control lists (ACLs) control which principals (account members, users, or roles) have permissions to access a resource. ACLs are similar to resource-based policies, although they do not use the JSON policy document format. Identity and Access Management 149 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide ABAC with AMB Access Hyperledger Fabric Supports ABAC (tags in policies): Yes Attribute-based access control (ABAC) is an authorization strategy that defines permissions based on attributes. In AWS, these attributes are called tags. You can attach tags to IAM entities (users or roles) and to many AWS resources. Tagging entities and resources is the first step of ABAC. Then you design ABAC policies to allow operations when the principal's tag matches the tag on the resource that they are trying to access. ABAC is helpful in environments that are growing rapidly and helps with situations where policy management becomes cumbersome. To control access based on tags, you provide tag information in the condition element of a policy using the aws:ResourceTag/key-name, aws:RequestTag/key-name, or aws:TagKeys condition keys. If a service supports all three condition keys for every resource type, then the value is Yes for the service. If a service supports all three condition keys for only some resource types, then the value is Partial. For more information about ABAC, see Define permissions with ABAC authorization in the IAM User Guide. To view a tutorial with steps for setting up ABAC, see Use attribute-based access control (ABAC) in the IAM User Guide. To control access based on tags, you provide tag information in the condition element of a policy using the managedblockchain::ResourceTag/key-name, aws:RequestTag/key-name, or aws:TagKeys condition keys. For more information about tagging AMB Access Hyperledger Fabric resources, see Tagging Amazon Managed Blockchain (AMB) resources. To view example identity-based policies for allowing or denying access to resources and actions based on tags, see Controlling access using tags. Using temporary credentials with AMB Access Hyperledger Fabric Supports temporary credentials: Yes Some AWS services don't work when you sign in using temporary credentials. For additional information, including which AWS services work with temporary credentials, see AWS services that work with IAM in the IAM User Guide. Identity and Access Management 150 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide You are using temporary credentials if you sign in to the AWS Management Console using any method except a user name and password. For example, when you access AWS using your company's single sign-on (SSO) link, that process automatically creates temporary credentials. You also automatically create temporary credentials when you sign in to the console as a user and then switch roles. For more information about switching roles, see Switch from a user to an IAM role (console) in the IAM User Guide. You can manually create temporary credentials using the AWS CLI or AWS API. You can then use those temporary credentials to access AWS. AWS recommends that you dynamically generate temporary credentials instead of using long-term access keys. For more information, see Temporary security credentials in IAM. Cross-service principal permissions for AMB Access Hyperledger Fabric Supports forward access sessions (FAS): Yes When you use an IAM user or role to perform actions in AWS, you are considered a principal. When you use some services, you might perform an action that then initiates another action in a different service. FAS uses the permissions of the principal calling an AWS service, combined with the requesting AWS service to make requests to downstream services. FAS requests are only made when a service receives a |
amazon-managed-blockchain-hyperledger-fabric-dev-056 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 56 | credentials instead of using long-term access keys. For more information, see Temporary security credentials in IAM. Cross-service principal permissions for AMB Access Hyperledger Fabric Supports forward access sessions (FAS): Yes When you use an IAM user or role to perform actions in AWS, you are considered a principal. When you use some services, you might perform an action that then initiates another action in a different service. FAS uses the permissions of the principal calling an AWS service, combined with the requesting AWS service to make requests to downstream services. FAS requests are only made when a service receives a request that requires interactions with other AWS services or resources to complete. In this case, you must have permissions to perform both actions. For policy details when making FAS requests, see Forward access sessions. Service roles for AMB Access Hyperledger Fabric Supports service roles: Yes A service role is an IAM role that a service assumes to perform actions on your behalf. An IAM administrator can create, modify, and delete a service role from within IAM. For more information, see Create a role to delegate permissions to an AWS service in the IAM User Guide. Warning Changing the permissions for a service role might break AMB Access Hyperledger Fabric functionality. Edit service roles only when AMB Access Hyperledger Fabric provides guidance to do so. Identity and Access Management 151 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Service-linked roles for AMB Access Hyperledger Fabric Supports service-linked roles: Yes A service-linked role is a type of service role that is linked to an AWS service. The service can assume the role to perform an action on your behalf. Service-linked roles appear in your AWS account and are owned by the service. An IAM administrator can view, but not edit the permissions for service-linked roles. For details about creating or managing service-linked roles, see AWS services that work with IAM. Find a service in the table that includes a Yes in the Service-linked role column. Choose the Yes link to view the service-linked role documentation for that service. Troubleshooting Amazon Managed Blockchain (AMB) Hyperledger Fabric identity and access Use the following information to help you diagnose and fix common issues that you might encounter when working with AMB Access Hyperledger Fabric and IAM. Topics • I am not authorized to perform an action in AMB Access Hyperledger Fabric • I am not authorized to perform iam:PassRole • I want to allow people outside of my AWS account to access my AMB Access Hyperledger Fabric resources I am not authorized to perform an action in AMB Access Hyperledger Fabric If you receive an error that you're not authorized to perform an action, your policies must be updated to allow you to perform the action. The following example error occurs when the mateojackson IAM user tries to use the console to view details about a fictional my-example-widget resource but doesn't have the fictional managedblockchain::GetWidget permissions. User: arn:aws:iam::123456789012:user/mateojackson is not authorized to perform: managedblockchain::GetWidget on resource: my-example-widget Identity and Access Management 152 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide In this case, the policy for the mateojackson user must be updated to allow access to the my- example-widget resource by using the managedblockchain::GetWidget action. If you need help, contact your AWS administrator. Your administrator is the person who provided you with your sign-in credentials. I am not authorized to perform iam:PassRole If you receive an error that you're not authorized to perform the iam:PassRole action, your policies must be updated to allow you to pass a role to AMB Access Hyperledger Fabric. Some AWS services allow you to pass an existing role to that service instead of creating a new service role or service-linked role. To do this, you must have permissions to pass the role to the service. The following example error occurs when an IAM user named marymajor tries to use the console to perform an action in AMB Access Hyperledger Fabric. However, the action requires the service to have permissions that are granted by a service role. Mary does not have permissions to pass the role to the service. User: arn:aws:iam::123456789012:user/marymajor is not authorized to perform: iam:PassRole In this case, Mary's policies must be updated to allow her to perform the iam:PassRole action. If you need help, contact your AWS administrator. Your administrator is the person who provided you with your sign-in credentials. I want to allow people outside of my AWS account to access my AMB Access Hyperledger Fabric resources You can create a role that users in other accounts or people outside of your organization can use to access your resources. You can specify who is trusted to assume the role. For services that support resource-based policies or access control lists (ACLs), you can use those policies to grant |
amazon-managed-blockchain-hyperledger-fabric-dev-057 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 57 | policies must be updated to allow her to perform the iam:PassRole action. If you need help, contact your AWS administrator. Your administrator is the person who provided you with your sign-in credentials. I want to allow people outside of my AWS account to access my AMB Access Hyperledger Fabric resources You can create a role that users in other accounts or people outside of your organization can use to access your resources. You can specify who is trusted to assume the role. For services that support resource-based policies or access control lists (ACLs), you can use those policies to grant people access to your resources. To learn more, consult the following: • To learn whether AMB Access Hyperledger Fabric supports these features, see How Amazon Managed Blockchain (AMB) Hyperledger Fabric works with IAM. Identity and Access Management 153 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • To learn how to provide access to your resources across AWS accounts that you own, see Providing access to an IAM user in another AWS account that you own in the IAM User Guide. • To learn how to provide access to your resources to third-party AWS accounts, see Providing access to AWS accounts owned by third parties in the IAM User Guide. • To learn how to provide access through identity federation, see Providing access to externally authenticated users (identity federation) in the IAM User Guide. • To learn the difference between using roles and resource-based policies for cross-account access, see Cross account resource access in IAM in the IAM User Guide. Amazon Managed Blockchain (AMB) Hyperledger Fabric Identity-Based Policy Examples By default, IAM users and roles don't have permission to create or modify AMB Access Hyperledger Fabric resources. They also can't perform tasks using the AWS Management Console, AWS CLI, or AWS API. An IAM administrator must create IAM policies that grant users and roles permission to perform specific API operations on the specified resources they need. The administrator must then attach those policies to the IAM users or groups that require those permissions. To learn how to create an IAM identity-based policy using these example JSON policy documents, see Creating Policies on the JSON Tab in the IAM User Guide. Topics • Policy Best Practices • Allow Users to View Their Own Permissions • Using the AMB Access Hyperledger Fabric Console • Performing All AMB Access Actions on All Accessible Networks for an AWS Account • Controlling access using tags Policy Best Practices Identity-based policies determine whether someone can create, access, or delete AMB Access Hyperledger Fabric resources in your account. These actions can incur costs for your AWS account. When you create or edit identity-based policies, follow these guidelines and recommendations: Identity and Access Management 154 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide • Get started with AWS managed policies and move toward least-privilege permissions – To get started granting permissions to your users and workloads, use the AWS managed policies that grant permissions for many common use cases. They are available in your AWS account. We recommend that you reduce permissions further by defining AWS customer managed policies that are specific to your use cases. For more information, see AWS managed policies or AWS managed policies for job functions in the IAM User Guide. • Apply least-privilege permissions – When you set permissions with IAM policies, grant only the permissions required to perform a task. You do this by defining the actions that can be taken on specific resources under specific conditions, also known as least-privilege permissions. For more information about using IAM to apply permissions, see Policies and permissions in IAM in the IAM User Guide. • Use conditions in IAM policies to further restrict access – You can add a condition to your policies to limit access to actions and resources. For example, you can write a policy condition to specify that all requests must be sent using SSL. You can also use conditions to grant access to service actions if they are used through a specific AWS service, such as AWS CloudFormation. For more information, see IAM JSON policy elements: Condition in the IAM User Guide. • Use IAM Access Analyzer to validate your IAM policies to ensure secure and functional permissions – IAM Access Analyzer validates new and existing policies so that the policies adhere to the IAM policy language (JSON) and IAM best practices. IAM Access Analyzer provides more than 100 policy checks and actionable recommendations to help you author secure and functional policies. For more information, see Validate policies with IAM Access Analyzer in the IAM User Guide. • Require multi-factor authentication (MFA) – If you have a scenario that requires IAM users or a root user in your AWS account, turn on MFA for additional security. To require MFA when |
amazon-managed-blockchain-hyperledger-fabric-dev-058 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 58 | IAM policies to ensure secure and functional permissions – IAM Access Analyzer validates new and existing policies so that the policies adhere to the IAM policy language (JSON) and IAM best practices. IAM Access Analyzer provides more than 100 policy checks and actionable recommendations to help you author secure and functional policies. For more information, see Validate policies with IAM Access Analyzer in the IAM User Guide. • Require multi-factor authentication (MFA) – If you have a scenario that requires IAM users or a root user in your AWS account, turn on MFA for additional security. To require MFA when API operations are called, add MFA conditions to your policies. For more information, see Secure API access with MFA in the IAM User Guide. For more information about best practices in IAM, see Security best practices in IAM in the IAM User Guide. Allow Users to View Their Own Permissions This example shows how you might create a policy that allows IAM users to view the inline and managed policies that are attached to their user identity. This policy includes permissions to complete this action on the console or programmatically using the AWS CLI or AWS API. { Identity and Access Management 155 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "Version": "2012-10-17", "Statement": [ { "Sid": "ViewOwnUserInfo", "Effect": "Allow", "Action": [ "iam:GetUserPolicy", "iam:ListGroupsForUser", "iam:ListAttachedUserPolicies", "iam:ListUserPolicies", "iam:GetUser" ], "Resource": ["arn:aws:iam::*:user/${aws:username}"] }, { "Sid": "NavigateInConsole", "Effect": "Allow", "Action": [ "iam:GetGroupPolicy", "iam:GetPolicyVersion", "iam:GetPolicy", "iam:ListAttachedGroupPolicies", "iam:ListGroupPolicies", "iam:ListPolicyVersions", "iam:ListPolicies", "iam:ListUsers" ], "Resource": "*" } ] } Using the AMB Access Hyperledger Fabric Console To access the Amazon Managed Blockchain (AMB) Hyperledger Fabric console, you must have a minimum set of permissions. These permissions must allow you to list and view details about the AMB Access Hyperledger Fabric resources in your AWS account. If you create an identity-based policy that is more restrictive than the minimum required permissions, the console won't function as intended for entities (IAM users or roles) with that policy. To ensure that those entities can still use the AMB Access Hyperledger Fabric console, also attach the following AWS managed policy to the entities. Identity and Access Management 156 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide AmazonManagedBlockchainConsoleFullAccess For more information, see Adding Permissions to a User in the IAM User Guide. You don't need to allow minimum console permissions for users that are making calls only to the AWS CLI or the AWS API. Instead, allow access to only the actions that match the API operation that you're trying to perform. Performing All AMB Access Actions on All Accessible Networks for an AWS Account The following example shows you how to grant an IAM user in AWS account 123456789012access to all the network and member resources in the account in the us-east-1 Region. This example shows how the user is permitted to list and create; manage networks, proposals, members, and nodes; and reject invitations to join other networks. Note • Deny and Allow actions on a resource (for example Network) only affect actions on the resource itself and do not apply to child resources such as Member and Node. • Child resources (such as nodes, members and invitations) must have AWS account ids in their policy so they can be enforced as shown in the following example. { "Version": "2012-10-17", "Statement": [{ "Sid": "ManageNetworkResources", "Effect": "Allow", "Action": [ "managedblockchain:CreateNetwork", "managedblockchain:GetNetwork", "managedblockchain:CreateProposal", "managedblockchain:ListProposals", "managedblockchain:CreateMember", "managedblockchain:ListMembers" ], "Resource": [ "arn:aws:managedblockchain:us-east-1::networks/*" ] }, Identity and Access Management 157 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide { "Sid": "ManageMemberResources", "Effect": "Allow", "Action": [ "managedblockchain:GetMember", "managedblockchain:DeleteMember", "managedblockchain:CreateNode", "managedblockchain:ListNodes" ], "Resource": [ "arn:aws:managedblockchain:us-east-1:123456789012:members/*" ] }, { "Sid": "ManageNodeResources", "Effect": "Allow", "Action": [ "managedblockchain:GetNode", "managedblockchain:DeleteNode", "managedblockchain:UpdateNode" ], "Resource": [ "arn:aws:managedblockchain:us-east-1:123456789012:nodes/*" ] }, { "Sid": "ManageProposalResources", "Effect": "Allow", "Action": [ "managedblockchain:GetProposal", "managedblockchain:ListProposalVotes", "managedblockchain:VoteOnProposal" ], "Resource": [ "arn:aws:managedblockchain:us-east-1::proposals/*" ] }, { "Sid": "ManageInvitationResources", "Effect": "Allow", Identity and Access Management 158 Amazon Managed Blockchain (AMB) "Action": [ Hyperledger Fabric Developer Guide "managedblockchain:RejectInvitation" ], "Resource": [ "arn:aws:managedblockchain:us-east-1:123456789012:invitations/*" ] } ] } Controlling access using tags The following example policy statements demonstrate how you can use tags to limit access to AMB Access Hyperledger Fabric resources and actions performed on those resources. To tag resources during creation, policy statements that allow the create action for the resource as well as the TagResource action must be attached to the IAM principal performing the operation. Note This topic includes examples of policy statements with a Deny effect. Each policy statement assumes that a statement with a broader Allow effect for the same actions exists; the Deny policy statement restricts that otherwise overly-permissive allow statement. Example – Require a tag key with either of two values to be added during network creation The following identity-based policy statements allow the IAM principal to create a network only if the network is created with the tags specified. |
amazon-managed-blockchain-hyperledger-fabric-dev-059 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 59 | create action for the resource as well as the TagResource action must be attached to the IAM principal performing the operation. Note This topic includes examples of policy statements with a Deny effect. Each policy statement assumes that a statement with a broader Allow effect for the same actions exists; the Deny policy statement restricts that otherwise overly-permissive allow statement. Example – Require a tag key with either of two values to be added during network creation The following identity-based policy statements allow the IAM principal to create a network only if the network is created with the tags specified. The statement with the Sid set to RequireTag specifies that network creation is allowed only if the network is created with a tag that has a tag key of department and a value of either sales or marketing; otherwise, the create network operation fails. The statement with Sid set to AllowTagging allows the IAM principal to tag networks, which are not associated with an AWS account ID. It also allows tagging of members in the specified AWS account, 111122223333. { "Version": "2012-10-17", "Statement": [ Identity and Access Management 159 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide { "Sid": "RequireTag", "Effect": "Allow", "Action": [ "managedblockchain:CreateNetwork" ], "Resource": [ "*" ], "Condition": { "StringLike": { "aws:RequestTag/department": [ "sales", "marketing" ] } } }, { "Sid": "AllowTagging", "Effect": "Allow", "Action": [ "managedblockchain:TagResource" ], "Resource": [ "arn:aws:managedblockchain:us-east-1::networks/*", "arn:aws:managedblockchain:us-east-1:111122223333:members/*" ] } ] } Example – Deny access to networks that have a specific tag key The following identity-based policy statement denies the IAM principal the ability to retrieve or view information for networks that have a tag with a tag key of restricted. { "Version": "2012-10-17", "Statement": [ { "Sid": "DenyRestrictedNetwork", "Effect": "Deny", Identity and Access Management 160 Hyperledger Fabric Developer Guide Amazon Managed Blockchain (AMB) "Action": [ "managedblockchain:GetNetwork" ], "Resource": [ "*" ], "Condition": { "StringLike": { "aws:ResourceTag/restricted": [ "*" ] } } } ] } Example – Deny member creation for networks with a specific tag key and value The following identity-based policy statement denies the IAM principal from creating a member on any network that has a tag with a tag key of department with the value of accounting. { "Version": "2012-10-17", "Statement": [ { "Sid": "DenyMemberCreation", "Effect": "Deny", "Action": [ "managedblockchain:CreateMember" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:ResourceTag/department": "accounting" } } } ] } Identity and Access Management 161 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Example – Allow member creation only if a specific tag key and value are added The following identity-based policy statements allow the IAM principal to create members in the account 111122223333 only if the member is created with a tag that has the tag key of department and a tag value of accounting; otherwise, the create member operation fails. { "Version": "2012-10-17", "Statement": [ { "Sid": "RestrictMemberCreation", "Effect": "Allow", "Action": [ "managedblockchain:CreateMember" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:RequestTag/department": "accounting" } } }, { "Sid": "AllowTaggingOfMembers", "Effect": "Allow", "Action": [ "managedblockchain:TagResource" ], "Resource": [ "arn:aws:managedblockchain:us-east-1:111122223333:members/*" ] } ] } Example – Allow access only to members that have a specified tag key The following identity-based policy statement allows the IAM principal to retrieve or view information about members only if the member has a tag with a tag key of unrestricted. Identity and Access Management 162 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide { "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Action": [ "managedblockchain:GetMember" ], "Resource": [ "*" ], "Condition": { "StringLike": { "aws:ResourceTag/unrestricted": [ "*" ] } } } ] } Example – Deny node creation if a specific tag key and value are added during creation The following identity-based policy statement denies the IAM principal the ability to create a node if a tag with the tag key of department and a value of analytics is added during creation. { "Version": "2012-10-17", "Statement": [ { "Sid": "DenyCreateNodeWithTag", "Effect": "Deny", "Action": [ "managedblockchain:CreateNode" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:RequestTag/department": [ Identity and Access Management 163 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "analytics" ] } } } ] } Example – Deny node creation for members with a specific tag key and value The following identity-based policy statement denies the IAM principal the ability to create a node if the member to which the node will belong has a tag with a tag key of department and a tag value of analytics. { "Version": "2012-10-17", "Statement": [ { "Sid": "DenyCreateNodeForTaggedMember", "Effect": "Deny", "Action": [ "managedblockchain:CreateNode" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:ResourceTag/department": [ "analytics" ] } } } ] } Example – Allow access only to nodes with a specific tag key and value The following identity-based policy statement allows the IAM principal to retrieve |
amazon-managed-blockchain-hyperledger-fabric-dev-060 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 60 | specific tag key and value The following identity-based policy statement denies the IAM principal the ability to create a node if the member to which the node will belong has a tag with a tag key of department and a tag value of analytics. { "Version": "2012-10-17", "Statement": [ { "Sid": "DenyCreateNodeForTaggedMember", "Effect": "Deny", "Action": [ "managedblockchain:CreateNode" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:ResourceTag/department": [ "analytics" ] } } } ] } Example – Allow access only to nodes with a specific tag key and value The following identity-based policy statement allows the IAM principal to retrieve or view information about nodes only if the node has a tag with a tag key of department and a tag value of sales. Identity and Access Management 164 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowTaggedNodeAccess", "Effect": "Allow", "Action": [ "managedblockchain:GetNode" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:ResourceTag/department": [ "sales" ] } } } ] } Example – Deny access to nodes with a specific tag key The following identity-based policy statement denies the IAM principal the ability to retrieve or view information about a node if the node has a tag with a tag key of restricted. { "Version": "2012-10-17", "Statement": [ { "Sid": "DenyAccessToTaggedNodes", "Effect": "Deny", "Action": [ "managedblockchain:GetNode" ], "Resource": [ "*" ], "Condition": { "StringLike": { "aws:ResourceTag/restricted": [ Identity and Access Management 165 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "*" ] } } } ] } Example – Allow proposal creation only for networks with a specific tag key and value The following identity-based policy statement allows the IAM principal to create a proposal only if the network for which the proposal is made has a tag with a tag key of department and a value of accounting. { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowCreateProposalOnlyForTaggedNetwork", "Effect": "Allow", "Action": [ "managedblockchain:CreateProposal" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:ResourceTag/department": [ "accounting" ] } } } ] } Example – Allow proposal creation only if a specific tag key and value are added The following identity-based policy statements allow the IAM principal to create a proposal for inviting the specified account 123456789012 to the network only if a tag with a tag key of consortium and a tag value of exampleconsortium is added during proposal creation. Identity and Access Management 166 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide { "Version": "2012-10-17", "Statement": [ { "Sid": "RequireTagWithProposal", "Effect": "Allow", "Action": [ "managedblockchain:CreateProposal" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:RequestTag/consortium": [ "exampleconsortium" ] } } }, { "Sid": "AllowProposalAndInvitationTagging", "Effect": "Allow", "Action": [ "managedblockchain:TagResource" ], "Resource": [ "arn:aws:managedblockchain:us-east-1::proposals/*", "arn:aws:managedblockchain:us-east-1:123456789012:invitations/*" ] } ] } Example – Allow access only to proposals with a specific tag key and value The following identity-based policy statement allows the IAM principal to retrieve and view proposals only if the proposal has a tag with a tag key of consortium and a tag value of exampleconsortium. { "Version": "2012-10-17", "Statement": [ Identity and Access Management 167 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide { "Sid": "AllowOnlyTaggedProposalAccess", "Effect": "Allow", "Action": [ "managedblockchain:GetProposal" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:ResourceTag/consortium": [ "exampleconsortium" ] } } } ] } Example – Deny the ability to vote on proposals based on a specific tag key and value The following identity-based policy statement denies the IAM principal the ability to vote on proposals that have a tag with the tag key of consortium and a tag value of exampleconsortium. { "Version": "2012-10-17", "Statement": [ { "Sid": "DenyVoteOnTaggedProposal", "Effect": "Deny", "Action": [ "managedblockchain:VoteOnProposal" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:ResourceTag/consortium": [ "exampleconsortium" ] Identity and Access Management 168 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide } } } ] } Example – Deny the ability to reject an invitation with a specific tag and value The following identity-based policy statement denies the IAM principal the ability to reject on invitation that has a tag with the tag key of consortium and a tag value of exampleconsortium. { "Version": "2012-10-17", "Statement": [ { "Sid": "1", "Effect": "Deny", "Action": [ "managedblockchain:RejectInvitation" ], "Resource": [ "*" ], "Condition": { "StringEquals": { "aws:ResourceTag/consortium": [ "exampleconsortium" ] } } } ] } Example IAM Role Permissions Policy for Hyperledger Fabric Client EC2 Instance When you administer, develop, and deploy chaincode using an EC2 instance as a Hyperledger Fabric client, the permissions policies attached to the AWS Identity and Access Management instance profile and instance role associated with the instance determine its permissions to interact with other AWS resources, including AMB Access. The permissions policy shown in the following procedure provides sufficient privileges when it is attached to the IAM role of the instance. Identity and Access Management 169 |
amazon-managed-blockchain-hyperledger-fabric-dev-061 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 61 | ], "Condition": { "StringEquals": { "aws:ResourceTag/consortium": [ "exampleconsortium" ] } } } ] } Example IAM Role Permissions Policy for Hyperledger Fabric Client EC2 Instance When you administer, develop, and deploy chaincode using an EC2 instance as a Hyperledger Fabric client, the permissions policies attached to the AWS Identity and Access Management instance profile and instance role associated with the instance determine its permissions to interact with other AWS resources, including AMB Access. The permissions policy shown in the following procedure provides sufficient privileges when it is attached to the IAM role of the instance. Identity and Access Management 169 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide The procedure demonstrates how to create a role with only this permissions policy attached and then attach that role to an EC2 instance. If you have an existing service role and instance profile attached to your EC2 instance, you can create an additional policy using the following example and then attach it to the existing role. Only one role can be attached to an EC2 instance. For more information, see IAM roles for Amazon EC2 in the Amazon EC2 User Guide. To create a permissions policy, attach it to an IAM role, and attach the role to a Hyperledger Fabric client EC2 instance 1. Open the IAM console at https://console.aws.amazon.com/iam/. 2. In the navigation pane, choose Policies, and then Create policy. 3. Choose the JSON tab, and then copy and paste the following policy statement. { "Version": "2012-10-17", "Statement": [ { "Sid": "ListNetworkMembers", "Effect": "Allow", "Action": [ "managedblockchain:GetNetwork", "managedblockchain:ListMembers" ], "Resource": [ "arn:aws:managedblockchain:*:123456789012:networks/*" ] }, { "Sid": "AccessManagedBlockchainBucket", "Effect": "Allow", "Action": [ "s3:GetObject" ], "Resource": "arn:aws:s3:::us-east-1.managedblockchain/*" }, { "Sid": "ManageNetworkResources", "Effect": "Allow", "Action": [ "managedblockchain:CreateProposal", "managedblockchain:GetProposal", Identity and Access Management 170 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "managedblockchain:DeleteMember", "managedblockchain:VoteOnProposal", "managedblockchain:ListProposals", "managedblockchain:GetNetwork", "managedblockchain:ListMembers", "managedblockchain:ListProposalVotes", "managedblockchain:RejectInvitation", "managedblockchain:GetNode", "managedblockchain:GetMember", "managedblockchain:DeleteNode", "managedblockchain:CreateNode", "managedblockchain:CreateMember", "managedblockchain:ListNodes" ], "Resource": [ "arn:aws:managedblockchain:*::networks/*", "arn:aws:managedblockchain:*::proposals/*", "arn:aws:managedblockchain:*:123456789012:members/*", "arn:aws:managedblockchain:*:123456789012:invitations/*", "arn:aws:managedblockchain:*:123456789012:nodes/*" ] }, { "Sid": "WorkWithNetworksForAcct", "Effect": "Allow", "Action": [ "managedblockchain:ListNetworks", "managedblockchain:ListInvitations", "managedblockchain:CreateNetwork" ], "Resource": "*" } ] } 4. Replace 123456789012 with your AWS Account ID. If you are working in a different Region, replace us-east-1 with the appropriate Region, and then choose Review policy. 5. Enter a Name for the policy, for example, HyperledgerFabricClientAccess. Enter an optional Description, and then choose Create policy. You now have a permissions policy that you can attach to an IAM role for an EC2 instance. 6. From the navigation pane, choose Roles, Create role. Identity and Access Management 171 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide 7. Under Select type of trusted entity, leave AWS service selected. Under Common use cases, choose EC2 - Allows EC2 instances to call AWS services on your behalf, and then choose Next: Permissions. 8. Under Attach permissions policies, start typing the name of the permissions policy you created in the previous steps. Select that policy from the list, and then choose Next: Tags. 9. Leave the key-value fields blank or type key-value pairs for any tags that you want to apply to this role, and then choose Next: Review. 10. Enter a Role name that helps you identify this role, for example, ServiceRoleForHyperledgerFabricClient. Enter an optional Description, and then choose Create role. You now have a service role with appropriate permissions that you can associate with your Hyperledger Fabric EC2 instance. 11. Open the EC2 console at https://console.aws.amazon.com/ec2/. 12. From the navigation pane, choose Instances. 13. From the list of instances, select the instance that you are using as a Hyperledger Fabric client. 14. Choose Actions, Security, Modify IAM role. 15. For IAM role begin typing the name of the role you created, for example, ServiceRoleForHyperledgerFabricClient. Select it from the list, and then choose Apply. Using Service-Linked Roles for AMB Access Amazon Managed Blockchain (AMB) uses AWS Identity and Access Management (IAM) service- linked roles. A service-linked role is a unique type of IAM role that is linked directly to AMB Access. Service-linked roles are predefined by AMB Access and include all the permissions that the service requires to call other AWS services on your behalf. A service-linked role can make setting up AMB Access easier because you don’t have to manually add the necessary permissions. AMB Access defines the permissions of its service-linked roles, and, unless defined otherwise, only AMB Access can assume its roles. The defined permissions include the trust policy and the permissions policy. The permissions policy cannot be attached to any other IAM entity. You can delete a service-linked role only after first deleting its related resources. This protects your AMB Access resources because you can't inadvertently remove permission to access the resources. Identity and Access Management 172 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide For information about other services that support service-linked roles, see AWS Services That Work with IAM and look |
amazon-managed-blockchain-hyperledger-fabric-dev-062 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 62 | defines the permissions of its service-linked roles, and, unless defined otherwise, only AMB Access can assume its roles. The defined permissions include the trust policy and the permissions policy. The permissions policy cannot be attached to any other IAM entity. You can delete a service-linked role only after first deleting its related resources. This protects your AMB Access resources because you can't inadvertently remove permission to access the resources. Identity and Access Management 172 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide For information about other services that support service-linked roles, see AWS Services That Work with IAM and look for the services that have Yes in the Service-Linked Role column. Choose a Yes with a link to view the service-linked role documentation for that service. Service-Linked Role Permissions for AMB Access AMB Access uses the service-linked role named AWSServiceRoleForAmazonManagedBlockchain. This role enables access to AWS Services and Resources used or managed by Amazon Managed Blockchain. The AWSServiceRoleForAmazonManagedBlockchain service-linked role trusts the following services to assume the role: • managedblockchain.amazonaws.com The role permissions policy allows AMB Access to complete actions on the specified resources shown in the following example policy. { "Version": "2012-10-17", "Statement": [ { "Action": [ "logs:CreateLogGroup" ], "Effect": "Allow", "Resource": "arn:aws:logs:*:*:log-group:/aws/managedblockchain/*" }, { "Effect": "Allow", "Action": [ "logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams" ], "Resource": [ "arn:aws:logs:*:*:log-group:/aws/managedblockchain/*:log-stream:*" ] } ] } Identity and Access Management 173 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide You must configure permissions to allow an IAM entity (such as a user, group, or role) to create, edit, or delete a service-linked role. For more information, see Service-Linked Role Permissions in the IAM User Guide. Creating a Service-Linked Role for AMB Access You don't need to manually create a service-linked role. When you create a network, a member, or a peer node, AMB Access creates the service-linked role for you. It doesn't matter if you use the AWS Management Console, the AWS CLI, or the AWS API. The IAM entity performing the action must have permissions to create the service-linked role. After the role is created in your account, AMB Access can use it for all networks and members. If you delete this service-linked role, and then need to create it again, you can use the same process to recreate the role in your account. When you create a network, member, or node, AMB Access creates the service-linked role for you again. Editing a Service-Linked Role for AMB Access AMB Access does not allow you to edit the AWSServiceRoleForAmazonManagedBlockchain service- linked role. After you create a service-linked role, you cannot change the name of the role because various entities might reference the role. However, you can edit the description of the role using IAM. For more information, see Editing a Service-Linked Role in the IAM User Guide. Deleting a Service-Linked Role for AMB Access If you no longer need to use a feature or service that requires a service-linked role, we recommend that you delete that role. That way you don’t have an unused entity that is not actively monitored or maintained. However, you must clean up the resources for your service-linked role before you can manually delete it. Note If the AMB Access service is using the role when you try to delete the resources, then the deletion might fail. If that happens, wait for a few minutes and try the operation again. To manually delete the service-linked role Identity and Access Management 174 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Use the IAM console, the AWS CLI, or the AWS API to delete the AWSServiceRoleForAmazonManagedBlockchain service-linked role. For more information, see Deleting a Service-Linked Role in the IAM User Guide. Supported Regions for AMB Access Service-Linked Roles AMB Access supports using service-linked roles in all of the Regions where the service is available. For more information, see AWS Regions and Endpoints. Configuring Security Groups for Amazon Managed Blockchain (AMB) Hyperledger Fabric Security groups act as virtual firewalls. They control inbound and outbound traffic between your Hyperledger Fabric client and network resources on AMB Access through the VPC endpoint in your account. By default, security group rules are restrictive, so you must add rules that allow traffic for any resources, such as client computers, that must access the network. The following tables list the minimum required security group rules that must be associated with the VPC endpoint and the Hyperledger Fabric client. VPC Endpoint Security Group Minimum Rules Inbound/Outbound Type Source/Destination Purpose Outbound All traffic 0.0.0/0 (Anywhere) Default. Allows unrestricted outbound traffic from the interface VPC endpoint to all recipients. Inbound Custom TCP, Port for Ordering Service (ranging between 30000 and 34000) —for example, 30001. The port is available within the Ordering service The IPv4 address, an address range, or a security group that includes all members' Hyperledger Fabric clients. Allows the Hyperledg |
amazon-managed-blockchain-hyperledger-fabric-dev-063 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 63 | computers, that must access the network. The following tables list the minimum required security group rules that must be associated with the VPC endpoint and the Hyperledger Fabric client. VPC Endpoint Security Group Minimum Rules Inbound/Outbound Type Source/Destination Purpose Outbound All traffic 0.0.0/0 (Anywhere) Default. Allows unrestricted outbound traffic from the interface VPC endpoint to all recipients. Inbound Custom TCP, Port for Ordering Service (ranging between 30000 and 34000) —for example, 30001. The port is available within the Ordering service The IPv4 address, an address range, or a security group that includes all members' Hyperledger Fabric clients. Allows the Hyperledg er Fabric ordering service to receive traffic from Hyperledger Fabric clients. Configuring Security Groups 175 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Inbound/Outbound Type Source/Destination Purpose endpoint on the network details page using the console and returned within the OrderingS erviceEndpoint property using the get-network command from the AWS CLI or using the GetNetwork API action. Configuring Security Groups 176 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Inbound/Outbound Type Source/Destination Purpose Inbound Custom TCP, Port for the CA Service for The IPv4 address, an address range, or a Allows the Hyperledg er Fabric certifica a member (ranging security group that te authority (CA) between 30000 and includes all members' for each member to 34000)—for example, Hyperledger Fabric receive traffic from respective Hyperledg er Fabric clients. 30002. This is unique clients. to each member, and each member only needs access to their own CA. The port is available within the Fabric certificate authority endpoint on the member details page using the console and returned within the CaEndpoin t property using the get-member command from the AWS CLI or using the GetMember API action. Configuring Security Groups 177 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Inbound/Outbound Type Source/Destination Purpose Inbound Custom TCP, Ports, or Range of Ports for The IPv4 address, an address range, or a Allows the network to receive traffic Peer Event Services security group that from peer nodes as on Peer Nodes includes all members' required. Each node (ranging between Hyperledger Fabric in each membershi 30000 and 34000). clients. The port is available within the Peer node endpoints on the member details page using the console and returned as the PeerEventPort property using the get-node command from the AWS CLI or using the GetNode API action. p has a unique port associated with its peer event service. Any node that might be a participant in an endorsement policy, regardless of membership, must be allowed communica tions in order to endorse transactions. Hyperledger Fabric Client Security Group Minimum Rules Inbound/Outbound Type Source/Destination Purpose Outbound All traffic 0.0.0/0 (Anywhere) Default. Allows unrestricted outbound traffic from the Hyperledg er Fabric client to all recipients. If necessary, you can limit the destination to the interface VPC endpoint. Configuring Security Groups 178 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Inbound/Outbound Type Source/Destination Purpose Inbound SSH (Port 22) The IP address, address range, or Allows trusted clients to use SSH security group that to connect to the includes trusted SSH Hyperledger Fabric clients that connect client to interact— to the Hyperledger for example, to query Fabric client. and run chaincode. Configuring Security Groups 179 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Tagging Amazon Managed Blockchain (AMB) resources A tag is a custom attribute label that you assign or that AWS assigns to an AWS resource. Each tag has two parts: • A tag key, such as CostCenter, Environment, or Project. Tag keys are case-sensitive. • An optional field known as a tag value, such as 111122223333 or Production. Omitting the tag value is the same as using an empty string. Like tag keys, tag values are case-sensitive. Tags help you do the following: • Identify and organize your AWS resources. Many AWS services support tagging, so you can assign the same tag to resources from different services to indicate that the resources are related. For example, you could assign the same tag to an Amazon Managed Blockchain (AMB) node and an EC2 instance that you use as a client for the AMB Access framework. • Track your AWS costs. You activate these tags on the AWS Billing and Cost Management dashboard. AWS uses the tags to categorize your costs and deliver a monthly cost allocation report to you. For more information, see Using cost allocation tags in the AWS Billing User Guide. • Control access to your AWS resources with AWS Identity and Access Management (IAM). For information, see Controlling access using tags in this developer guide and Control access using IAM tags in the IAM User Guide. For more information about tags, see the Tagging Best Practices guide. The following sections provide more information about tags for AMB Access. Create and add tags for AMB Access Hyperledger Fabric resources |
amazon-managed-blockchain-hyperledger-fabric-dev-064 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 64 | dashboard. AWS uses the tags to categorize your costs and deliver a monthly cost allocation report to you. For more information, see Using cost allocation tags in the AWS Billing User Guide. • Control access to your AWS resources with AWS Identity and Access Management (IAM). For information, see Controlling access using tags in this developer guide and Control access using IAM tags in the IAM User Guide. For more information about tags, see the Tagging Best Practices guide. The following sections provide more information about tags for AMB Access. Create and add tags for AMB Access Hyperledger Fabric resources You can tag the following resources: • Networks • Members • Nodes Create and add tags for AMB Access Hyperledger Fabric resources 180 Amazon Managed Blockchain (AMB) • Proposals and invitations Hyperledger Fabric Developer Guide Members can assign tags to proposals when they create them. If a proposal is approved and an invitation is sent, the invitation inherits the tags added during proposal creation. Members who receive invitations or vote on proposals can subsequently add or remove tags for proposals and invitations. These subsequent tag edits are scoped only to the AWS account that made the edits. Tags that you create—including those for network-wide resources like networks, proposals, and invitations—are scoped only to the account in which you create them. Tags created during proposal creation are the exception. Other AWSaccounts participating on the network cannot access the tags. Tag naming and usage conventions The following basic naming and usage conventions apply to tags used with AMB Access resources: • Each resource can have a maximum of 50 tags. • For each resource, each tag key must be unique, and each tag key can have only one value. • The maximum tag key length is 128 Unicode characters in UTF-8. • The maximum tag value length is 256 Unicode characters in UTF-8. • Allowed characters are letters, numbers, spaces representable in UTF-8, and the following characters: . : + = @ _ / - (hyphen). • Tag keys and values are case-sensitive. As a best practice, decide on a strategy for capitalizing tags, and consistently implement that strategy across all resource types. For example, decide whether to use Costcenter, costcenter, or CostCenter, and use the same convention for all tags. Avoid using similar tags with inconsistent case treatment. • The aws: prefix is reserved for AWS use. You can't edit or delete a tag's key or value when the tag has a tag key with the aws: prefix. Tags with this prefix do not count against your limit of tags per resource. Working with tags You can use the AMB Access console, the AWS CLI, or the AMB Access API to add, edit, or delete tag keys and tag values. You can assign tags when you create a resource, or you can apply tags after the resource is created. Tag naming and usage conventions 181 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide For more information about AMB Access API actions for tagging, see the following topics in the Amazon Managed Blockchain (AMB) API Reference: • ListTagsForResource • TagResource • UntagResource Add or remove tags You can add a tag to AMB Access Hyperledger Fabric resources when you create or work with them. Topics • Add or remove tags for networks • Add or remove tags for members • Add or remove tags for nodes • Add or remove tags for proposals • Add or remove tags for invitations Add or remove tags for networks For information about adding a tag when you create a network, see Create a Hyperledger Fabric Blockchain Network on Amazon Managed Blockchain (AMB). To add or remove a tag for a Hyperledger Fabric network on AMB Access using the AWS Management Console 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks and then choose a Hyperledger Fabric network from the list. 3. Under Tags, choose Edit tags, and then do one of the following: • To add a tag, choose Add new tag, enter a Key and optional Value, and then choose Save. • To remove a tag, choose Remove next to the Tag you want to remove, and then choose Save. Add or remove tags 182 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Add or remove tags for members For information about adding a tag when you create a member, see Create a Member and Join a Network. To add or remove a tag for a member 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks and then choose a Hyperledger Fabric network from the list. 3. Choose Members. 4. Under Members owned by you, choose a member from the list. 5. Under Tags, choose Edit tags, and then do one of the following: • To add a tag, choose |
amazon-managed-blockchain-hyperledger-fabric-dev-065 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 65 | remove tags 182 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Add or remove tags for members For information about adding a tag when you create a member, see Create a Member and Join a Network. To add or remove a tag for a member 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks and then choose a Hyperledger Fabric network from the list. 3. Choose Members. 4. Under Members owned by you, choose a member from the list. 5. Under Tags, choose Edit tags, and then do one of the following: • To add a tag, choose Add new tag, enter a Key and optional Value, and then choose Save. • To remove a tag, choose Remove next to the Tag you want to remove, and then choose Save. Add or remove tags for nodes For information about adding a tag when you create a node, see Create a Hyperledger Fabric Peer Node on Amazon Managed Blockchain (AMB). To add or remove a tag for a node 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks and then choose a Hyperledger Fabric network from the list. 3. Choose Members. 4. Under Members owned by you, choose a member from the list. 5. Under peer nodes, choose a Node ID from the list. 6. Choose Tags, choose Edit tags, and then do one of the following: • To add a tag, choose Add new tag, enter a Key and optional Value, and then choose Save. • To remove a tag, choose Remove next to the Tag you want to remove, and then choose Save. Add or remove tags 183 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Add or remove tags for proposals For information about adding a tag when you create a proposal, see Create an Invitation Proposal and Create a Proposal to Remove a Network Member. You can add and remove tags from active and completed proposals. To add or remove a tag for a proposal 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Networks and then choose a network from the list. 3. Choose Proposals. 4. Under Active or Completed, choose a Proposal ID from the list. 5. Under Tags, choose Edit tags, and then do one of the following: • To add a tag, choose Add new tag, enter a Key and optional Value, and then choose Save. • To remove a tag, choose Remove next to the Tag you want to remove, and then choose Save. Add or remove tags for invitations If the member who created a proposal for an invitation tagged the proposal, the invitation inherits the tag key and value from the proposal. To add or remove a tag for an invitation 1. Open the AMB Access console at https://console.aws.amazon.com/managedblockchain/. 2. Choose Invitations and then choose a Network name from the list. 3. Under Tags, choose Edit tags, and then do one of the following: • To add a tag, choose Add new tag, enter a Key and optional Value, and then choose Save. • To remove a tag, choose Remove next to the Tag you want to remove, and then choose Save. Add or remove tags 184 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Monitoring AMB Access Hyperledger Fabric Using CloudWatch Logs Amazon Managed Blockchain (AMB) Hyperledger Fabric supports publishing peer node, chaincode, and certificate authority (CA) logs to Amazon CloudWatch Logs. You can use these logs to troubleshoot during chaincode development and to monitor network activity and errors. You can enable and view logs in the AMB Access management console, in the CloudWatch Logs console, and using AWS CLI commands for CloudWatch Logs. In addition, you can set up metric filters in CloudWatch Logs to turn log data into numerical CloudWatch metrics that you can graph and set an alarm on. For each member that has logging enabled, AMB Access creates a log group in CloudWatch Logs. For more information about CloudWatch Logs, see the Amazon CloudWatch Logs User Guide. For more information about creating metric filters, see Searching and Filtering Log Data in the Amazon CloudWatch Logs User Guide. • Peer node logs help you debug timeout errors associated with proposals and identify rejected proposals that do not meet the endorsement policies. Peer node logs contain messages generated when your client submits transaction proposals to peer nodes, requests to join channels, enrolls an admin peer, and lists the chaincode instances on a peer node. Peer node logs also contain the results of chaincode installation. You can enable and disable logs on individual peer nodes. • Chaincode logs help you analyze and debug the business logic and execution of chaincode on a peer node. They contain the results of invoking, and querying the chaincode. A peer can run multiple instances of chaincode. When |
amazon-managed-blockchain-hyperledger-fabric-dev-066 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 66 | identify rejected proposals that do not meet the endorsement policies. Peer node logs contain messages generated when your client submits transaction proposals to peer nodes, requests to join channels, enrolls an admin peer, and lists the chaincode instances on a peer node. Peer node logs also contain the results of chaincode installation. You can enable and disable logs on individual peer nodes. • Chaincode logs help you analyze and debug the business logic and execution of chaincode on a peer node. They contain the results of invoking, and querying the chaincode. A peer can run multiple instances of chaincode. When you enable chaincode logging, individual log streams are created for each and every chaincode on the peer. • CA logs help you determine when a member in your account joins the network, or when new peers register with a member CA. You can use CA logs to debug problems related to certificates and enrollment. CA logging can be enabled and disabled for each member. A single log stream for the CA exists for each member. Note AMB Access gathers CloudWatch metrics for peer nodes automatically and separately from CloudWatch Logs for CAs, peer nodes, and chaincode. For more information, see Use Hyperledger Fabric Peer Node Metrics on Amazon Managed Blockchain (AMB). 185 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Considerations and Limitations Consider the following before you enable and view CloudWatch Logs for AMB Access Hyperledger Fabric. • CA logs can be enabled only for members created after April 6, 2020. Peer node logs and chaincode logs can be enabled only for peer nodes created after April 6, 2020. • Log entries are updated every five seconds. • Logging requires the service-linked role for AMB Access. The role is created automatically when an IAM principal (user or role) in your account with permissions to create the service-linked role creates a network, member, or peer. For more information, see Using Service-Linked Roles for AMB Access. • Logging currently does not support CloudWatch Logs encryption. • Logging currently does not support CloudWatch Logs Insights. • To log chaincode events, you must first configure Go chaincode for logging. For more information, see Logging Control for Chaincode in the Hyperledger Fabric documentation. Enabling and Disabling Logs You can enable logs using the AMB Access management console when you create a member or node, or at any time after a member or node is created. You can disable CA logging, peer node logging, and chaincode logging at any time. When a log is disabled, log entries are not published to CloudWatch Logs. Previous log entries are still viewable and available in CloudWatch Logs. Enabling and Disabling Peer Node and Chaincode Logs You can enable peer node logs, chaincode logs, or both when you create a peer node or when viewing information about a peer node. You can also disable logs while viewing information about a peer node. To enable peer node or chaincode logs when you create a node 1. On the Members tab of the network that you are working with, under Members owned by you, choose the name of the member from the list, and then choose Create peer node. 2. Under Logging configuration, choose Enable peer node logs, Enable chaincode logs, or both, and then choose Create peer node. Considerations and Limitations 186 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide To enable or disable peer node and chaincode logs for an existing member 1. On the Members tab of the network that you are working with, under Members owned by you, choose the name of the member from the list. 2. Under Peer nodes, choose the Node ID of the peer. 3. Under monitoring, choose Peer node logs or Chaincode logs. 4. Choose Enable logging, or choose Actions and then Disable Logging. Enabling and Disabling CA Logs You can enable CA logs when you create a member or when viewing information about a member. There are two ways you can create members. One is when you create a new network, you must also create the first member. The other is when you receive an invite to create a member to join an existing network. You can only disable CA logs while viewing information about a member. To enable CA logs when you create a member • Under the Logging configuration section in the member creation form, choose Enable certificate authority logs. To enable or disable CA logs for an existing member 1. On the Members tab of the network that you are working with, under Members owned by you, choose the name of the member from the list. 2. Under CA logged events, choose the Enable logging, or choose Actions and then Disable logging. Working with Logged Events in the AMB Access Console AMB Access publishes logged events to CloudWatch |
amazon-managed-blockchain-hyperledger-fabric-dev-067 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 67 | while viewing information about a member. To enable CA logs when you create a member • Under the Logging configuration section in the member creation form, choose Enable certificate authority logs. To enable or disable CA logs for an existing member 1. On the Members tab of the network that you are working with, under Members owned by you, choose the name of the member from the list. 2. Under CA logged events, choose the Enable logging, or choose Actions and then Disable logging. Working with Logged Events in the AMB Access Console AMB Access publishes logged events to CloudWatch Logs every five seconds. By default, logged events are updated every five seconds in the AMB Access console under Logged events on member and node information pages. When viewing logged events in AMB Access, you can choose Actions and then view View in CloudWatch to open the CloudWatch Logs management console focused on the log stream that you are viewing. Choose the gear icon to configure the logging interval and other details. Enabling and Disabling CA Logs 187 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Searching (Filtering) Logged Events While viewing events for any log in AMB Access, you can enter a keyword or phrase in the Search events box to show only those events that contain the search term. For example, you can enter a date, a date and time, or a log level such as CRITICAL, DEBUG, or WARNING. When you download a log after searching, only the events filtered by your search term are downloaded. Downloading Logged Events Choose Actions and then Download while viewing any log in AMB Access to save the events that are loaded to the default download directory on your local machine with a .log extension. Logged events are listed along with a header that contains log information as shown in the following example. Event Count: 100 Filtered: Yes Filtered Event Count: 44 Filter: "DEBUG" 2020-02-03T01:04:34.548Z 2020/02/03 01:04:34 [DEBUG] Cleaning up expired nonces for CA 'm-J46DNSFRTVCCLONS9DT5TTLS2A' 2020-02-03T01:00:56.382Z 2020/02/03 01:00:56 [DEBUG] Received request for /cainfo 2020-02-03T00:55:56.308Z 2020/02/03 00:55:56 [DEBUG] Received request for /cainfo 2020-02-03T00:50:56.208Z 2020/02/03 00:50:56 [DEBUG] Received request for /cainfo 2020-02-03T00:49:34.544Z 2020/02/03 00:49:34 [DEBUG] Cleaning up expired nonces for CA 'm-J46DNSFRTVCCLONS9DT5TTLS2A' Searching (Filtering) Logged Events 188 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide 2020-02-03T00:45:56.282Z 2020/02/03 00:45:56 [DEBUG] Received request for /cainfo 2020-02-03T00:40:56.111Z 2020/02/03 00:40:56 [DEBUG] Received request for /cainfo 2020-02-03T00:35:56.026Z 2020/02/03 00:35:56 [DEBUG] Received request for /cainfo 2020-02-03T00:34:34.539Z 2020/02/03 00:34:34 [DEBUG] Cleaning up expired nonces for CA 'm-J46DNSFRTVCCLONS9DT5TTLS2A' 2020-02-03T00:30:56.081Z 2020/02/03 00:30:56 [DEBUG] Received request for /cainfo 2020-02-03T00:25:56.123Z 2020/02/03 00:25:56 [DEBUG] Received request for /cainfo 2020-02-03T00:20:56.197Z 2020/02/03 00:20:56 [DEBUG] Received request for /cainfo Viewing Different Chaincode Logs When viewing chaincode logs for a peer node with multiple chaincodes, you can choose the chaincode to view by choosing the chaincode name from the list next to Logged events. When you download a log, only the logged events for the chaincode that you are viewing are downloaded. Viewing Different Chaincode Logs 189 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Identifying Logs in CloudWatch Logs Each set of log events in AMB Access corresponds to a log stream in CloudWatch Logs. The easiest way to access a log stream in the CloudWatch Logs management console is to choose Actions and then View in CloudWatch while viewing a log in the AMB Access management console. All log streams associated with a member and peer nodes that a member owns are in a log group with the naming pattern shown below—for example, aws/managedblockchain/n- MWY63ZJZU5HGNCMBQER7IN6OIU/m-J46DNSFRTVCCLONS9DT5TTLS2A. aws/managedblockchain/NetworkID/MemberID Log streams in the log group are named according to the patterns in the table below. Type of log Stream name Peer node logs PeerNodeID , for example, nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y. Chaincode logs MemberID-PeerNodeID -ChaincodeName -ChaincodeVersion , for example, m-J46DNSFRTVCCLONS9DT5TTLS2A-nd-6EAJ5VA43JGGN PXOUZP7Y47E4Y-MyChaincode-v0. CA logs ca Identifying Logs in CloudWatch Logs 190 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Logging Amazon Managed Blockchain API calls using AWS CloudTrail Amazon Managed Blockchain is integrated with AWS CloudTrail, a service that provides a record of actions taken by a user, role, or an AWS service in Managed Blockchain. CloudTrail captures all API calls for Managed Blockchain as events. The calls captured include calls from the Managed Blockchain console and code calls to the Managed Blockchain API operations. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for Managed Blockchain. If you don't configure a trail, you can still view the most recent events in the CloudTrail console in Event history. Using the information collected by CloudTrail, you can determine the request that was made to Managed Blockchain, the IP address from which the request was made, who made the request, when it was made, and additional details. To learn more about CloudTrail, see the AWS |
amazon-managed-blockchain-hyperledger-fabric-dev-068 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 68 | Blockchain console and code calls to the Managed Blockchain API operations. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for Managed Blockchain. If you don't configure a trail, you can still view the most recent events in the CloudTrail console in Event history. Using the information collected by CloudTrail, you can determine the request that was made to Managed Blockchain, the IP address from which the request was made, who made the request, when it was made, and additional details. To learn more about CloudTrail, see the AWS CloudTrail User Guide. Managed Blockchain information in CloudTrail CloudTrail is enabled on your AWS account when you create the account. When activity occurs in Managed Blockchain, that activity is recorded in a CloudTrail event along with other AWS service events in Event history. You can view, search, and download recent events in your AWS account. For more information, see Viewing events with CloudTrail Event history. For an ongoing record of events in your AWS account, including events for Managed Blockchain, create a trail. A trail enables CloudTrail to deliver log files to an Amazon S3 bucket. By default, when you create a trail in the console, the trail applies to all AWS Regions. The trail logs events from all Regions in the AWS partition and delivers the log files to the Amazon S3 bucket that you specify. Additionally, you can configure other AWS services to further analyze and act upon the event data collected in CloudTrail logs. For more information, see the following: • Overview for Creating a trail • CloudTrail supported services and integrations • Configuring Amazon SNS notifications for CloudTrail • Receiving CloudTrail log files from multiple Regions and Receiving CloudTrail log files from multiple accounts Managed Blockchain information in CloudTrail 191 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide All Managed Blockchain actions are logged by CloudTrail and are documented in the Amazon Managed Blockchain API Reference. For example, calls to the CreateNode, GetNode and DeleteNetwork actions generate entries in the CloudTrail log files. Every event or log entry contains information about who generated the request. The identity information helps you determine the following: • Whether the request was made with root or AWS Identity and Access Management (IAM) user credentials. • Whether the request was made with temporary security credentials for a role or federated user. • Whether the request was made by another AWS service. For more information, see the CloudTrail userIdentity element. Understanding Managed Blockchain log file entries A trail is a configuration that enables delivery of events as log files to an Amazon S3 bucket that you specify. CloudTrail log files contain one or more log entries. An event represents a single request from any source and includes information about the requested action, the date and time of the action, request parameters, and so on. CloudTrail log files aren't an ordered stack trace of the public API calls, so they don't appear in any specific order. The following example shows a CloudTrail log entry that demonstrates the GetNode action. { "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "ABCD1EF23G4EXAMPLE56:carlossalazar", "arn": "arn:aws:sts::111122223333:assumed-role/Admin/carlossalazar", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "ABCD1EF23G4EXAMPLE56", "arn": "arn:aws:iam::111122223333:role/Admin", "accountId": "111122223333", "userName": "Admin" }, Understanding Managed Blockchain log file entries 192 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide "webIdFederationData": {}, "attributes": { "mfaAuthenticated": "false", "creationDate": "2020-12-10T05:36:38Z" } } }, "eventTime": "2020-12-10T05:50:48Z", "eventSource": "managedblockchain.amazonaws.com", "eventName": "GetNode", "awsRegion": "us-east-1", "sourceIPAddress": "198.51.100.1", "userAgent": "aws-cli/2.0.7 Python/3.7.3 Linux/5.4.58-37.125.amzn2int.x86_64 botocore/2.0.0dev11", "requestParameters": { "networkId": "n-MWY63ZJZU5HGNCMBQER7IN6OIU", "nodeId": "nd-6EAJ5VA43JGGNPXOUZP7Y47E4Y" }, "responseElements": null, "requestID": "1e2xa3m4-56p7-8l9e-0ex1-23456a78m90p", "eventID": "ex12345a-m678-901p-23e4-567ex8a9mple", "readOnly": true, "eventType": "AwsApiCall", "recipientAccountId": "111122223333" } Understanding Managed Blockchain log file entries 193 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Document History for Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide The following table describes important additions to the Amazon Managed Blockchain (AMB) Management Guide. For notification about updates to this documentation, you can subscribe to the RSS feed. Change Description Date Amazon Managed Blockchain (AMB) Access Updated terminology to change Amazon Managed July 27, 2023 Updated for Hyperledger Fabric v2.2. Blockchain to Amazon Managed Blockchain (AMB) Access. Updated channel configura tion file examples, Java chaincode examples, and getting started tutorial for Hyperledger Fabric v2.2. January 4, 2022 Updated for support of customer managed AWS KMS Updated for support of encryption at rest using June 10, 2021 keys. Guide updated to be specific to AMB Access Hyperledger Fabric. customer managed keys in AWS Key Management Service (AWS KMS) for new member resources. Updated title from Amazon Managed Blockchain (AMB) Management Guide to Amazon Managed Blockchai n (AMB) Hyperledger Fabric Developer Guide in conjunction with release of Ethereum framework November 15, 2020 194 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide support. Slight changes to content throughout, clarifyin g |
amazon-managed-blockchain-hyperledger-fabric-dev-069 | amazon-managed-blockchain-hyperledger-fabric-dev.pdf | 69 | getting started tutorial for Hyperledger Fabric v2.2. January 4, 2022 Updated for support of customer managed AWS KMS Updated for support of encryption at rest using June 10, 2021 keys. Guide updated to be specific to AMB Access Hyperledger Fabric. customer managed keys in AWS Key Management Service (AWS KMS) for new member resources. Updated title from Amazon Managed Blockchain (AMB) Management Guide to Amazon Managed Blockchai n (AMB) Hyperledger Fabric Developer Guide in conjunction with release of Ethereum framework November 15, 2020 194 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide support. Slight changes to content throughout, clarifyin g applicability to Hyperledg er Fabric networks, members, peer nodes, and chaincode. Updated for Hyperledger Fabric v1.4, including anchor Added sections on setting up anchor peers, setting up peers, private data collectio channels, using private data ns, Java chaincode. collections, and running Java September 14, 2020 chaincode. Updated getting started tutorial for Hyperledg er Fabric v1.4. Added new peer node metrics. Updated for support of Amazon CloudWatch Logs Added Monitoring chapter for publishing peer node, and streamlined Getting chaincode, and CA logs to Started experience. CloudWatch Logs. Miscellan April 6, 2020 eous improvements to getting started tutorial to streamline and simplify. Major updates for new proposal and voting work Updated Getting Started tutorial, conceptual informati April 8, 2019 flow for member invitations on, and procedures for new and removals voting proposal design. 195 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide Added security group configuration guidance February 28, 2019 Added prescriptive guidance for configuring security groups for the tutorial. Added references for minimum inbound and outbound security group rules required for Hyperledger Fabric client and interface VPC endpoint for reference and customiza tion. Updates to getting started steps Removed redundant steps in 3.2. The step to December 3, 2018 update .bash_profile with path to fabric-ca was already covered in step 3.1. Initial release of Amazon Managed Blockchain (AMB) Initial documentation for Amazon Managed Blockchain November 28, 2018 (Preview) (AMB). 196 Amazon Managed Blockchain (AMB) Hyperledger Fabric Developer Guide AWS Glossary For the latest AWS terminology, see the AWS glossary in the AWS Glossary Reference. 197 |
amazon-managed-prometheus-user-guide-001 | amazon-managed-prometheus-user-guide.pdf | 1 | User Guide Amazon Managed Service for Prometheus Copyright © 2025 Amazon Web Services, Inc. and/or its affiliates. All rights reserved. Amazon Managed Service for Prometheus User Guide Amazon Managed Service for Prometheus: User Guide Copyright © 2025 Amazon Web Services, Inc. and/or its affiliates. All rights reserved. Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who may or may not be affiliated with, connected to, or sponsored by Amazon. Amazon Managed Service for Prometheus Table of Contents User Guide What is Amazon Managed Service for Prometheus? ..................................................................... 1 Supported Regions ....................................................................................................................................... 1 Pricing ............................................................................................................................................................. 7 Premium support .......................................................................................................................................... 7 Get started ....................................................................................................................................... 8 Set up AWS .................................................................................................................................................... 8 Sign up for an AWS account ................................................................................................................ 9 Create a user with administrative access ........................................................................................... 9 Create a workspace .................................................................................................................................... 10 Ingest metrics .............................................................................................................................................. 11 Step 1: Add new Helm chart repositories ....................................................................................... 12 Step 2: Create a Prometheus namespace ........................................................................................ 13 Step 3: Set up IAM roles for service accounts ................................................................................ 13 Step 4: Set up the new server and start ingesting metrics .......................................................... 13 Query metrics ............................................................................................................................................. 15 Manage workspaces ....................................................................................................................... 17 Create a workspace .................................................................................................................................... 17 Configure your workspace ........................................................................................................................ 20 Edit a workspace alias ............................................................................................................................... 21 Find your workspace details .................................................................................................................... 22 Delete a workspace .................................................................................................................................... 24 Ingest metrics ................................................................................................................................ 25 AWS managed collectors .......................................................................................................................... 26 Using a managed collector ................................................................................................................. 26 Prometheus-compatible metrics ........................................................................................................ 46 Customer managed collectors ................................................................................................................. 47 Secure the ingestion of your metrics ............................................................................................... 47 ADOT collectors ..................................................................................................................................... 48 Prometheus collectors ......................................................................................................................... 65 High-availability data ........................................................................................................................... 74 Query your metrics ........................................................................................................................ 82 Secure your metric queries ...................................................................................................................... 82 Using AWS PrivateLink with Amazon Managed Service for Prometheus .................................. 47 Authentication and authorization ..................................................................................................... 48 iii Amazon Managed Service for Prometheus User Guide Use Amazon Managed Grafana ............................................................................................................... 83 Connecting to Amazon Managed Grafana in a private VPC ........................................................ 84 Use Grafana open source ......................................................................................................................... 84 Prerequisites ........................................................................................................................................... 84 Step 1: Set up AWS SigV4 .................................................................................................................. 85 Step 2: Add the Prometheus data source in Grafana .................................................................... 86 Step 3: (optional) Troubleshooting if Save & Test doesn't work ................................................. 88 Use Grafana in Amazon EKS .................................................................................................................... 89 Set up AWS SigV4 ................................................................................................................................ 89 Set up IAM roles for service accounts .............................................................................................. 90 Upgrade the Grafana server using Helm ......................................................................................... 91 Add the Prometheus data source in Grafana .................................................................................. 92 Use direct queries ...................................................................................................................................... 93 Query with awscurl .............................................................................................................................. 93 Query statistics ........................................................................................................................................... 96 Recording and alerting rules ........................................................................................................ 99 Necessary IAM permissions .................................................................................................................... 100 Create a rules file .................................................................................................................................... 101 Upload a rules file ................................................................................................................................... 103 Edit a rules file ......................................................................................................................................... 105 Troubleshooting Ruler ............................................................................................................................ 106 Alert manager .............................................................................................................................. 108 Necessary IAM permissions .................................................................................................................... 109 Create a configuration file ..................................................................................................................... 110 Set up an alert receiver .......................................................................................................................... 112 Create Amazon SNS topic ................................................................................................................. 113 Amazon SNS permissions needed ................................................................................................... 113 Send alerts to your Amazon SNS topic ......................................................................................... 116 Send messages as JSON ................................................................................................................... 118 Send alerts to other destinations ................................................................................................... 119 Amazon SNS validation rules ........................................................................................................... 121 Upload a configuration file .................................................................................................................... 122 Integrate alerts with Grafana ................................................................................................................ 125 Prerequisites ........................................................................................................................................ 125 Setting up Amazon Managed Grafana ........................................................................................... 126 Troubleshoot alert manager .................................................................................................................. 127 iv Amazon Managed Service for Prometheus User Guide Empty content warning .................................................................................................................... 127 Non ASCII warning ............................................................................................................................. 128 Invalid key/value warning ............................................................................................................. 128 Message limit warning ...................................................................................................................... 129 No resource based policy error ........................................................................................................ 129 Not authorized to call KMS .............................................................................................................. 130 Monitoring workspaces ............................................................................................................... 131 CloudWatch metrics ................................................................................................................................ 131 Setting a CloudWatch alarm ............................................................................................................ 138 CloudWatch Logs ..................................................................................................................................... 138 Configuring CloudWatch Logs ......................................................................................................... 139 Understand and optimize costs .................................................................................................. 142 What contributes to my costs? ............................................................................................................. 142 What is the best way to lower my costs? How do I lower ingestion costs? .................................. 142 What is the best way to lower my query costs? ............................................................................... 142 If I decrease the retention period of my metrics, will that help reduce my total bill? ................ 143 How can I keep my alert query costs low? ........................................................................................ 143 What metrics can I use to monitor my costs? ................................................................................... 144 Can I check my bill at any time? .......................................................................................................... 144 Why is my bill higher at the beginning of the month than at the end of the month? ............... 144 I deleted all my Amazon Managed Service for Prometheus workspaces, but I still seem to be getting charged. What might be happening? .................................................................................... 145 Integrations .................................................................................................................................. 146 Amazon EKS cost monitoring ................................................................................................................ 146 AWS Observability Accelerator ............................................................................................................. 147 Prerequisites ........................................................................................................................................ 147 Using the infrastructure monitoring example .............................................................................. 148 AWS Controllers for Kubernetes ........................................................................................................... 149 Prerequisites ........................................................................................................................................ 150 |
amazon-managed-prometheus-user-guide-002 | amazon-managed-prometheus-user-guide.pdf | 2 | ........................................................................................ 143 What metrics can I use to monitor my costs? ................................................................................... 144 Can I check my bill at any time? .......................................................................................................... 144 Why is my bill higher at the beginning of the month than at the end of the month? ............... 144 I deleted all my Amazon Managed Service for Prometheus workspaces, but I still seem to be getting charged. What might be happening? .................................................................................... 145 Integrations .................................................................................................................................. 146 Amazon EKS cost monitoring ................................................................................................................ 146 AWS Observability Accelerator ............................................................................................................. 147 Prerequisites ........................................................................................................................................ 147 Using the infrastructure monitoring example .............................................................................. 148 AWS Controllers for Kubernetes ........................................................................................................... 149 Prerequisites ........................................................................................................................................ 150 Deploying a workspace ..................................................................................................................... 151 Configure cluster for remote write ................................................................................................. 155 Amazon CloudWatch metrics with Firehose ....................................................................................... 157 Infrastructure ....................................................................................................................................... 157 Creating a Amazon CloudWatch stream ........................................................................................ 159 Cleanup ................................................................................................................................................. 160 Security ........................................................................................................................................ 162 v Amazon Managed Service for Prometheus User Guide Data protection ........................................................................................................................................ 163 Data collected by Amazon Managed Service for Prometheus .................................................. 164 Encryption at rest ............................................................................................................................... 164 Identity and Access Management ........................................................................................................ 177 Audience ............................................................................................................................................... 178 Authenticating with identities ......................................................................................................... 179 Managing access using policies ....................................................................................................... 182 How Amazon Managed Service for Prometheus works with IAM ............................................. 184 Identity-based policy examples ....................................................................................................... 191 AWS managed policies ...................................................................................................................... 194 Troubleshooting .................................................................................................................................. 205 IAM permissions and policies ................................................................................................................ 207 Amazon Managed Service for Prometheus permissions ............................................................ 207 Sample IAM policies ........................................................................................................................... 207 Compliance Validation ............................................................................................................................ 208 Resilience ................................................................................................................................................... 209 Infrastructure Security ............................................................................................................................ 209 Using service-linked roles ...................................................................................................................... 210 Metric scraping role ........................................................................................................................... 210 CloudTrail logs .......................................................................................................................................... 212 Amazon Managed Service for Prometheus management events in CloudTrail ..................... 214 Amazon Managed Service for Prometheus event examples ...................................................... 214 Set up IAM roles for service accounts ................................................................................................. 219 Set up service roles for the ingestion of metrics from Amazon EKS clusters ......................... 219 Set up IAM roles for service accounts for the querying of metrics .......................................... 222 Interface VPC endpoints ......................................................................................................................... 225 Create an interface VPC endpoint for Amazon Managed Service for Prometheus ................ 226 Troubleshooting ........................................................................................................................... 229 429 or limit exceeded errors ................................................................................................................. 229 I see duplicate samples .......................................................................................................................... 230 I see errors about sample timestamps ................................................................................................ 231 I see an error message related to a limit ........................................................................................... 231 Your local Prometheus server output exceeds the limit. ................................................................. 232 Some of my data isn't appearing ......................................................................................................... 233 Tagging ......................................................................................................................................... 234 Tagging workspaces ................................................................................................................................ 235 vi Amazon Managed Service for Prometheus User Guide Add a tag to a workspace ................................................................................................................ 235 View tags for a workspace ............................................................................................................... 237 Edit tags for a workspace ................................................................................................................. 238 Remove a tag from a workspace .................................................................................................... 239 Tagging rule groups namespaces ......................................................................................................... 241 Add a tag to a rule groups namespace ......................................................................................... 241 View tags for a rule groups namespace ........................................................................................ 243 Edit tags for a rule groups namespace .......................................................................................... 244 Remove a tag from a rule groups namespace ............................................................................. 245 Service quotas ............................................................................................................................. 247 Service quotas .......................................................................................................................................... 247 Active series default ........................................................................................................................... 253 Ingestion throttling ............................................................................................................................ 253 Additional limits on ingested data ....................................................................................................... 254 API Reference ............................................................................................................................... 255 Amazon Managed Service for Prometheus APIs ............................................................................... 255 Using Amazon Managed Service for Prometheus with an AWS SDK ....................................... 255 Prometheus-compatible APIs ................................................................................................................ 256 CreateAlertManagerAlerts ................................................................................................................. 257 DeleteAlertManagerSilence .............................................................................................................. 258 GetAlertManagerStatus ..................................................................................................................... 259 GetAlertManagerSilence .................................................................................................................... 260 GetLabels .............................................................................................................................................. 261 GetMetricMetadata ............................................................................................................................. 264 GetSeries ............................................................................................................................................... 265 ListAlerts ............................................................................................................................................... 267 ListAlertManagerAlerts ...................................................................................................................... 268 ListAlertManagerAlertGroups ........................................................................................................... 269 ListAlertManagerReceivers ................................................................................................................ 271 ListAlertManagerSilences .................................................................................................................. 272 ListRules ................................................................................................................................................ 274 PutAlertManagerSilences .................................................................................................................. 275 QueryMetrics ........................................................................................................................................ 277 RemoteWrite ........................................................................................................................................ 279 Document History ........................................................................................................................ 281 vii Amazon Managed Service for Prometheus User Guide What is Amazon Managed Service for Prometheus? Amazon Managed Service for Prometheus is a serverless, Prometheus-compatible monitoring service for container metrics that makes it easier to securely monitor container environments at scale. With Amazon Managed Service for Prometheus, you can use the same open-source Prometheus data model and query language that you use today to monitor the performance of your containerized workloads, and also enjoy improved scalability, availability, and security without having to manage the underlying infrastructure. Amazon Managed Service for Prometheus automatically scales the ingestion, storage, and querying of operational metrics as workloads scale up and down. It integrates with AWS security services to enable fast and secure access to data. Amazon Managed Service for Prometheus is designed to be highly available using multiple Availability Zone (Multi-AZ) deployments. Data ingested into a workspace is replicated across three Availability Zones in the same Region. Amazon Managed Service for Prometheus works with container clusters that run on Amazon Elastic Kubernetes Service and self-managed Kubernetes environments. With Amazon Managed Service for Prometheus, you use the same open-source Prometheus data model and PromQL query language that you use with Prometheus. Engineering teams can use PromQL to filter, aggregate, and alarm on metrics and quickly gain performance visibility without any code changes. Amazon Managed Service for Prometheus provides flexible query capabilities without the operational |
amazon-managed-prometheus-user-guide-003 | amazon-managed-prometheus-user-guide.pdf | 3 | be highly available using multiple Availability Zone (Multi-AZ) deployments. Data ingested into a workspace is replicated across three Availability Zones in the same Region. Amazon Managed Service for Prometheus works with container clusters that run on Amazon Elastic Kubernetes Service and self-managed Kubernetes environments. With Amazon Managed Service for Prometheus, you use the same open-source Prometheus data model and PromQL query language that you use with Prometheus. Engineering teams can use PromQL to filter, aggregate, and alarm on metrics and quickly gain performance visibility without any code changes. Amazon Managed Service for Prometheus provides flexible query capabilities without the operational cost and complexity. Metrics ingested into a workspace are stored for 150 days by default, and are then automatically deleted. This length is an adjustable quota. Supported Regions Amazon Managed Service for Prometheus currently supports the following Regions: Region Endpoint Protocol us-east-2 aps.us-east-2.amazonaws.com HTTPS Region Name US East (Ohio) Supported Regions 1 Amazon Managed Service for Prometheus User Guide Region Name Region Endpoint Protocol aps-workspaces.us-east-2.amazonaws.com HTTPS aps-workspaces-fips.us-east-2.amazon aws.com aps-workspaces-fips.us-east-2.api.aws aps-workspaces.us-east-2.api.aws aps-fips.us-east-2.amazonaws.com aps.us-east-2.api.aws aps-fips.us-east-2.api.aws HTTPS HTTPS HTTPS HTTPS HTTPS HTTPS US East (N. Virginia) us-east-1 aps.us-east-1.amazonaws.com HTTPS aps-workspaces.us-east-1.amazonaws.com HTTPS aps-workspaces-fips.us-east-1.amazon aws.com aps-workspaces-fips.us-east-1.api.aws aps-workspaces.us-east-1.api.aws aps-fips.us-east-1.amazonaws.com aps.us-east-1.api.aws aps-fips.us-east-1.api.aws HTTPS HTTPS HTTPS HTTPS HTTPS HTTPS Supported Regions 2 Amazon Managed Service for Prometheus User Guide Region Name Region Endpoint Protocol US West (Oregon) us- west-2 aps.us-west-2.amazonaws.com HTTPS aps-workspaces.us-west-2.amazonaws.com HTTPS aps-workspaces-fips.us-west-2.amazon HTTPS aws.com aps-workspaces-fips.us-west-2.api.aws aps-workspaces.us-west-2.api.aws aps-fips.us-west-2.amazonaws.com aps.us-west-2.api.aws aps-fips.us-west-2.api.aws HTTPS HTTPS HTTPS HTTPS HTTPS Asia Pacific (Mumbai) ap- south-1 aps.ap-south-1.amazonaws.com HTTPS aps-workspaces.ap-south-1.amazonaws.com HTTPS Asia Pacific (Seoul) ap- northe ast-2 aps-workspaces.ap-south-1.api.aws aps.ap-south-1.api.aws aps.ap-northeast-2.amazonaws.com aps-workspaces.ap-northeast-2.amazon aws.com aps-workspaces.ap-northeast-2.api.aws aps.ap-northeast-2.api.aws HTTPS HTTPS HTTPS HTTPS HTTPS HTTPS Supported Regions 3 Amazon Managed Service for Prometheus User Guide Region Name Region Endpoint Protocol Asia Pacific ap- southe (Singapor ast-1 e) Asia Pacific ap- southe (Sydney) ast-2 aps.ap-southeast-1.amazonaws.com HTTPS aps-workspaces.ap-southeast-1.amazon HTTPS aws.com aps-workspaces.ap-southeast-1.api.aws aps.ap-southeast-1.api.aws aps.ap-southeast-2.amazonaws.com aps-workspaces.ap-southeast-2.amazon aws.com aps-workspaces.ap-southeast-2.api.aws aps.ap-southeast-2.api.aws HTTPS HTTPS HTTPS HTTPS HTTPS HTTPS Asia Pacific (Tokyo) ap- northe ast-1 aps.ap-northeast-1.amazonaws.com HTTPS aps-workspaces.ap-northeast-1.amazon HTTPS aws.com aps-workspaces.ap-northeast-1.api.aws aps.ap-northeast-1.api.aws HTTPS HTTPS Supported Regions 4 Amazon Managed Service for Prometheus User Guide Region Name Region Endpoint Protocol Canada (Central) ca-centra l-1 aps.ca-central-1.amazonaws.com HTTPS aps-workspaces.ca-central-1.amazonaws.com HTTPS aps-workspaces-fips.ca-central-1.ama zonaws.com aps-workspaces-fips.ca-central-1.api.aws aps-workspaces.ca-central-1.api.aws aps-fips.ca-central-1.amazonaws.com aps.ca-central-1.api.aws aps-fips.ca-central-1.api.aws HTTPS HTTPS HTTPS HTTPS HTTPS HTTPS Europe (Frankfur eu- central-1 t) aps.eu-central-1.amazonaws.com HTTPS aps-workspaces.eu-central-1.amazonaws.com HTTPS Europe (Ireland) eu- west-1 aps-workspaces.eu-central-1.api.aws aps.eu-central-1.api.aws aps.eu-west-1.amazonaws.com HTTPS HTTPS HTTPS aps-workspaces.eu-west-1.amazonaws.com HTTPS aps-workspaces.eu-west-1.api.aws aps.eu-west-1.api.aws HTTPS HTTPS Supported Regions 5 Amazon Managed Service for Prometheus User Guide Region Name Region Endpoint Protocol Europe (London) eu- west-2 aps.eu-west-2.amazonaws.com HTTPS aps-workspaces.eu-west-2.amazonaws.com HTTPS aps-workspaces.eu-west-2.api.aws aps.eu-west-2.api.aws aps.eu-west-3.amazonaws.com HTTPS HTTPS HTTPS aps-workspaces.eu-west-3.amazonaws.com HTTPS aps-workspaces.eu-west-3.api.aws aps.eu-west-3.api.aws aps.eu-north-1.amazonaws.com HTTPS HTTPS HTTPS aps-workspaces.eu-north-1.amazonaws.com HTTPS Europe (Paris) eu- west-3 Europe (Stockhol eu- north-1 m) aps-workspaces.eu-north-1.api.aws aps.eu-north-1.api.aws sa-east-1 aps.sa-east-1.amazonaws.com HTTPS HTTPS HTTPS aps-workspaces.sa-east-1.amazonaws.com HTTPS aps-workspaces.sa-east-1.api.aws aps.sa-east-1.api.aws HTTPS HTTPS South America (São Paulo) Amazon Managed Service for Prometheus includes control plane endpoints (to perform workspace management tasks) and data plane endpoints (to work with Prometheus-compatible data in a workspace instance). Control plane endpoints start with aps.*, and dataplane endpoints start with aps-workspaces.*. Endpoints that end in .amazonaws.com support IPv4, and endpoints that end in .api.aws support both IPv4 and IPv6. Supported Regions 6 Amazon Managed Service for Prometheus User Guide Pricing You incur charges for ingestion and storage of metrics. Storage charges are based on the compressed size of metric samples and metadata. For more information, see Amazon Managed Service for Prometheus Pricing. You can use AWS Cost Explorer and AWS Cost and Usage Reports to monitor your charges. For more information, see Exploring your data using Cost Explorer and What are AWS Cost and Usage Reports. Premium support If you subscribe to any level of the AWS premium support plans, your premium support applies to Amazon Managed Service for Prometheus. Pricing 7 Amazon Managed Service for Prometheus User Guide Get started with Amazon Managed Service for Prometheus Amazon Managed Service for Prometheus is a serverless, Prometheus-compatible service for monitoring container metrics that makes it easy to securely monitor container environments at scale. This section takes you through three key areas of using Amazon Managed Service for Prometheus: • Create a workspace – Create a Amazon Managed Service for Prometheus workspace to store and monitor your metrics. • Ingest metrics – Your workspace is empty until you get metrics into your workspace. You can send metrics to Amazon Managed Service for Prometheus, or have Amazon Managed Service for Prometheus scrape metrics automatically. • Query metrics – Once you have metrics as data in your workspace, you are ready to query the data to explore or monitor those metrics. If you are new to AWS, this section also includes details about setting up an AWS account. Topics • Set up AWS • Create an Amazon Managed Service for Prometheus workspace • Ingest Prometheus metrics to the workspace • Query your Prometheus metrics Set up AWS Complete the tasks in this section |
amazon-managed-prometheus-user-guide-004 | amazon-managed-prometheus-user-guide.pdf | 4 | your workspace. You can send metrics to Amazon Managed Service for Prometheus, or have Amazon Managed Service for Prometheus scrape metrics automatically. • Query metrics – Once you have metrics as data in your workspace, you are ready to query the data to explore or monitor those metrics. If you are new to AWS, this section also includes details about setting up an AWS account. Topics • Set up AWS • Create an Amazon Managed Service for Prometheus workspace • Ingest Prometheus metrics to the workspace • Query your Prometheus metrics Set up AWS Complete the tasks in this section to get set up with AWS for the first time. If you already have an AWS account, skip ahead to Create an Amazon Managed Service for Prometheus workspace. When you sign up for AWS, your AWS account automatically has access to all services in AWS, including Amazon Managed Service for Prometheus. However, you are charged only for the services that you use. Topics • Sign up for an AWS account Set up AWS 8 Amazon Managed Service for Prometheus User Guide • Create a user with administrative access Sign up for an AWS account If you do not have an AWS account, complete the following steps to create one. To sign up for an AWS account 1. Open https://portal.aws.amazon.com/billing/signup. 2. Follow the online instructions. Part of the sign-up procedure involves receiving a phone call and entering a verification code on the phone keypad. When you sign up for an AWS account, an AWS account root user is created. The root user has access to all AWS services and resources in the account. As a security best practice, assign administrative access to a user, and use only the root user to perform tasks that require root user access. AWS sends you a confirmation email after the sign-up process is complete. At any time, you can view your current account activity and manage your account by going to https://aws.amazon.com/ and choosing My Account. Create a user with administrative access After you sign up for an AWS account, secure your AWS account root user, enable AWS IAM Identity Center, and create an administrative user so that you don't use the root user for everyday tasks. Secure your AWS account root user 1. Sign in to the AWS Management Console as the account owner by choosing Root user and entering your AWS account email address. On the next page, enter your password. For help signing in by using root user, see Signing in as the root user in the AWS Sign-In User Guide. 2. Turn on multi-factor authentication (MFA) for your root user. For instructions, see Enable a virtual MFA device for your AWS account root user (console) in the IAM User Guide. Sign up for an AWS account 9 Amazon Managed Service for Prometheus User Guide Create a user with administrative access 1. Enable IAM Identity Center. For instructions, see Enabling AWS IAM Identity Center in the AWS IAM Identity Center User Guide. 2. In IAM Identity Center, grant administrative access to a user. For a tutorial about using the IAM Identity Center directory as your identity source, see Configure user access with the default IAM Identity Center directory in the AWS IAM Identity Center User Guide. Sign in as the user with administrative access • To sign in with your IAM Identity Center user, use the sign-in URL that was sent to your email address when you created the IAM Identity Center user. For help signing in using an IAM Identity Center user, see Signing in to the AWS access portal in the AWS Sign-In User Guide. Assign access to additional users 1. In IAM Identity Center, create a permission set that follows the best practice of applying least- privilege permissions. For instructions, see Create a permission set in the AWS IAM Identity Center User Guide. 2. Assign users to a group, and then assign single sign-on access to the group. For instructions, see Add groups in the AWS IAM Identity Center User Guide. Create an Amazon Managed Service for Prometheus workspace A workspace is a logical space dedicated to the storage and querying of Prometheus metrics. A workspace supports fine-grained access control for authorizing its management such as update, list, describe, and delete, and the ingestion and querying of metrics. You can have one or more workspaces in each Region in your account. To set up a workspace, follow these steps. Create a workspace 10 Amazon Managed Service for Prometheus User Guide Note For more detailed information about creating a workspace and the options available, see Create a Amazon Managed Service for Prometheus workspace. To create a Amazon Managed Service for Prometheus workspace 1. Open the Amazon Managed Service for Prometheus console at https:// console.aws.amazon.com/prometheus/. 2. For Workspace alias, enter an |
amazon-managed-prometheus-user-guide-005 | amazon-managed-prometheus-user-guide.pdf | 5 | control for authorizing its management such as update, list, describe, and delete, and the ingestion and querying of metrics. You can have one or more workspaces in each Region in your account. To set up a workspace, follow these steps. Create a workspace 10 Amazon Managed Service for Prometheus User Guide Note For more detailed information about creating a workspace and the options available, see Create a Amazon Managed Service for Prometheus workspace. To create a Amazon Managed Service for Prometheus workspace 1. Open the Amazon Managed Service for Prometheus console at https:// console.aws.amazon.com/prometheus/. 2. For Workspace alias, enter an alias for the new workspace. Workspace aliases are friendly names that help you identify your workspaces. They do not have to be unique. Two workspaces could have the same alias, but all workspaces will have unique workspace IDs, which are generated by Amazon Managed Service for Prometheus. 3. (Optional) To add tags to the namespace, choose Add new tag. Then, for Key, enter a name for the tag. You can add an optional value for the tag in Value. To add another tag, choose Add new tag again. 4. Choose Create workspace. The workspace details page appears. This displays information including the status, ARN, workspace ID, and endpoint URLs for this workspace for both remote write and queries. Initially, the status is probably CREATING. Wait until the status is ACTIVE before you move on to setting up your metric ingestion. Make notes of the URLs displayed for Endpoint - remote write URL and Endpoint - query URL. You'll need them when you configure your Prometheus server to remote write metrics to this workspace and when you query those metrics. Ingest Prometheus metrics to the workspace One way to ingest metrics is to use a standalone Prometheus agent (a Prometheus instance running in agent mode) to scrape metrics from your cluster and forward them to Amazon Managed Service for Prometheus for storage and monitoring. This section explains how to set up the Ingest metrics 11 Amazon Managed Service for Prometheus User Guide ingestion of metrics into your Amazon Managed Service for Prometheus workspace from Amazon EKS by setting up a new instance of Prometheus agent using Helm. For information about other ways to ingest data into Amazon Managed Service for Prometheus, including how to secure metrics and create high-availability metrics, see Ingest metrics to your Amazon Managed Service for Prometheus workspace. Note Metrics ingested into a workspace are stored for 150 days by default, and are then automatically deleted. This length is an adjustable quota. The instructions in this section get you up and running with Amazon Managed Service for Prometheus quickly. It assumes that you have already created a workspace. In this section, you set up a new Prometheus server in an Amazon EKS cluster, and the new server uses a default configuration to act as an agent to send metrics to Amazon Managed Service for Prometheus. This method has the following prerequisites: • You must have an Amazon EKS cluster from which the new Prometheus server will collect metrics. • Your Amazon EKS cluster must have an Amazon EBS CSI driver installed (required by Helm). • You must use Helm CLI 3.0 or later. • You must use a Linux or MacOS computer to perform the steps in the following sections. Step 1: Add new Helm chart repositories To add new Helm chart repositories, enter the following commands. For more information about these commands, see Helm Repo. helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo add kube-state-metrics https://kubernetes.github.io/kube-state-metrics helm repo update Step 1: Add new Helm chart repositories 12 Amazon Managed Service for Prometheus User Guide Step 2: Create a Prometheus namespace Enter the following command to create a Prometheus namespace for the Prometheus server and other monitoring components. Replace prometheus-agent-namespace with the name that you want for this namespace. kubectl create namespace prometheus-agent-namespace Step 3: Set up IAM roles for service accounts For this method of ingestion, you need to use IAM roles for service accounts in the Amazon EKS cluster where the Prometheus agent is running. With IAM roles for service accounts, you can associate an IAM role with a Kubernetes service account. This service account can then provide AWS permissions to the containers in any pod that uses that service account. For more information, see IAM roles for service accounts. If you have not already set up these roles, follow the instructions at Set up service roles for the ingestion of metrics from Amazon EKS clusters to set up the roles. The instructions in that section require the use of eksctl. For more information, see Getting started with Amazon Elastic Kubernetes Service – eksctl. Note When you are not on EKS or AWS and using just access key and secret key to access Amazon Managed Service for |
amazon-managed-prometheus-user-guide-006 | amazon-managed-prometheus-user-guide.pdf | 6 | provide AWS permissions to the containers in any pod that uses that service account. For more information, see IAM roles for service accounts. If you have not already set up these roles, follow the instructions at Set up service roles for the ingestion of metrics from Amazon EKS clusters to set up the roles. The instructions in that section require the use of eksctl. For more information, see Getting started with Amazon Elastic Kubernetes Service – eksctl. Note When you are not on EKS or AWS and using just access key and secret key to access Amazon Managed Service for Prometheus, you cannot use the EKS-IAM-ROLE based SigV4. Step 4: Set up the new server and start ingesting metrics To install the new Prometheus agent and send metrics to your Amazon Managed Service for Prometheus workspace, follow these steps. To install a new Prometheus agent and send metrics to your Amazon Managed Service for Prometheus workspace 1. Use a text editor to create a file named my_prometheus_values_yaml with the following content. Step 2: Create a Prometheus namespace 13 Amazon Managed Service for Prometheus User Guide • Replace IAM_PROXY_PROMETHEUS_ROLE_ARN with the ARN of the amp-iamproxy-ingest- role that you created in Set up service roles for the ingestion of metrics from Amazon EKS clusters. • Replace WORKSPACE_ID with the ID of your Amazon Managed Service for Prometheus workspace. • Replace REGION with the Region of your Amazon Managed Service for Prometheus workspace. ## The following is a set of default values for prometheus server helm chart which enable remoteWrite to AMP ## For the rest of prometheus helm chart values see: https://github.com/prometheus- community/helm-charts/blob/main/charts/prometheus/values.yaml ## serviceAccounts: server: name: amp-iamproxy-ingest-service-account annotations: eks.amazonaws.com/role-arn: ${IAM_PROXY_PROMETHEUS_ROLE_ARN} server: remoteWrite: - url: https://aps-workspaces.${REGION}.amazonaws.com/workspaces/ ${WORKSPACE_ID}/api/v1/remote_write sigv4: region: ${REGION} queue_config: max_samples_per_send: 1000 max_shards: 200 capacity: 2500 2. Enter the following command to create the Prometheus server. • Replace prometheus-chart-name with your Prometheus release name. • Replace prometheus-agent-namespace with the name of your Prometheus namespace. helm install prometheus-chart-name prometheus-community/prometheus -n prometheus- agent-namespace \ -f my_prometheus_values_yaml Step 4: Set up the new server and start ingesting metrics 14 Amazon Managed Service for Prometheus User Guide Query your Prometheus metrics Now that metrics are being ingested to the workspace, you can query them. A common way to query your metrics is to use a service such as Grafana to query the metrics. In this section, you will learn how to use Amazon Managed Grafana to query metrics from Amazon Managed Service for Prometheus. Note To learn about other ways to query your Amazon Managed Service for Prometheus metrics, or use the Amazon Managed Service for Prometheus APIs, see Query your Prometheus metrics. This section assumes you already have a workspace created, and are ingesting metrics into it. You perform your queries using the standard Prometheus query language, PromQL. For more information about PromQL and its syntax, see Querying Prometheus in the Prometheus documentation. Amazon Managed Grafana is a fully managed service for open-source Grafana that simplifies connecting to open-source, third-party ISV, and AWS services for visualizing and analyzing your data sources at scale. Amazon Managed Service for Prometheus supports using Amazon Managed Grafana to query metrics in a workspace. In the Amazon Managed Grafana console, you can add an Amazon Managed Service for Prometheus workspace as a data source by discovering your existing Amazon Managed Service for Prometheus accounts. Amazon Managed Grafana manages the configuration of the authentication credentials that are required to access Amazon Managed Service for Prometheus. For detailed instructions on creating a connection to Amazon Managed Service for Prometheus from Amazon Managed Grafana, see the instructions in the Amazon Managed Grafana User Guide. You may also view your Amazon Managed Service for Prometheus alerts in Amazon Managed Grafana. For instructions to set up integration with alerts, see Integrate alerts with Amazon Managed Grafana or open source Grafana. Query metrics 15 Amazon Managed Service for Prometheus User Guide Note If you have configured your Amazon Managed Grafana workspace to use a Private VPC, you must connect your Amazon Managed Service for Prometheus workspace to the same VPC. For more information, see Connecting to Amazon Managed Grafana in a private VPC. Query metrics 16 Amazon Managed Service for Prometheus User Guide Manage Amazon Managed Service for Prometheus workspaces A workspace is a logical space dedicated to the storage and querying of Prometheus metrics. A workspace supports fine-grained access control for authorizing its management such as update, list, describe, and delete, and the ingestion and querying of metrics. You can have one or more workspaces in each Region in your account. Use the procedures in this section to create and manage your Amazon Managed Service for Prometheus workspaces. Topics • Create a Amazon Managed Service for Prometheus workspace • Configure your workspace • Edit a workspace alias • Find your Amazon Managed Service for |
amazon-managed-prometheus-user-guide-007 | amazon-managed-prometheus-user-guide.pdf | 7 | Managed Service for Prometheus workspaces A workspace is a logical space dedicated to the storage and querying of Prometheus metrics. A workspace supports fine-grained access control for authorizing its management such as update, list, describe, and delete, and the ingestion and querying of metrics. You can have one or more workspaces in each Region in your account. Use the procedures in this section to create and manage your Amazon Managed Service for Prometheus workspaces. Topics • Create a Amazon Managed Service for Prometheus workspace • Configure your workspace • Edit a workspace alias • Find your Amazon Managed Service for Prometheus workspace details, including ARN • Delete an Amazon Managed Service for Prometheus workspace Create a Amazon Managed Service for Prometheus workspace Follow these steps to create a Amazon Managed Service for Prometheus workspace. You can choose to use the AWS CLI or the Amazon Managed Service for Prometheus console. Note If you are running an Amazon EKS cluster, you can also create a new workspace using AWS Controllers for Kubernetes. To create a workspace using the AWS CLI 1. Enter the following command to create the workspace. This example creates a workspace named my-first-workspace, but you can use a different alias (or none) if you want. Workspace aliases are friendly names that help you identify your workspaces. They do not have to be unique. Two workspaces can have the same alias, but all workspaces have unique workspace IDs, which are generated by Amazon Managed Service for Prometheus. Create a workspace 17 Amazon Managed Service for Prometheus User Guide (Optional) To use your own KMS key to encrypt data stored in your workspace, you can include the kmsKeyArn parameter with the AWS KMS key to use. While Amazon Managed Service for Prometheus does not charge you for using customer managed keys, there may be costs associated with keys from AWS Key Management Service. For more information about Amazon Managed Service for Prometheus encryption of data in the workspace, or how to create, manage, and use your own customer managed key, see Encryption at rest. Parameters in brackets ([]) are optional, do not include the brackets in your command. aws amp create-workspace [--alias my-first-workspace] [--kmsKeyArn arn:aws:aps:us- west-2:111122223333:workspace/ws-sample-1234-abcd-56ef-7890abcd12ef] [-- tags Status=Secret,Team=My-Team] This command returns the following data: • workspaceId is the unique ID for this workspace. Make a note of this ID. • arn is the ARN for this workspace. • status is the current status of the workspace. Immediately after you create the workspace, this will probably be CREATING. • kmsKeyArn is the customer managed key used to encrypt the workspace data, if given. Note Workspaces created with customer managed keys cannot use AWS managed collectors for ingestion. Choose whether to use customer managed keys or AWS owned keys carefully. Workspaces created with customer managed keys can't be converted to use AWS owned keys later (and vice versa). • tags lists the workspace's tags, if any. 2. If your create-workspace command returns a status of CREATING, you can then enter the following command to determine when the workspace is ready. Replace my-workspace-id with the value that the create-workspace command returned for workspaceId. aws amp describe-workspace --workspace-id my-workspace-id Create a workspace 18 Amazon Managed Service for Prometheus User Guide When the describe-workspace command returns ACTIVE for status, the workspace is ready to use. To create a workspace using the Amazon Managed Service for Prometheus console 1. Open the Amazon Managed Service for Prometheus console at https:// console.aws.amazon.com/prometheus/. 2. Choose Create. 3. For Workspace alias, enter an alias for the new workspace. Workspace aliases are friendly names that help you identify your workspaces. They do not have to be unique. Two workspaces can have the same alias, but all workspaces have unique workspace IDs, which are generated by Amazon Managed Service for Prometheus. 4. (Optional) To use your own KMS key to encrypt data stored in your workspace, you can select Customize encryption settings, and choose the AWS KMS key to use (or create a new one). You can choose a key in your account from the drop down list, or enter the ARN for any key that you have access to. While Amazon Managed Service for Prometheus does not charge you for using customer managed keys, there may be costs associated with keys from AWS Key Management Service. For more information about Amazon Managed Service for Prometheus encryption of data in the workspace, or how to create, manage, and use your own, customer managed key, see Encryption at rest. Note Workspaces created with customer managed keys cannot use AWS managed collectors for ingestion. Choose whether to use customer managed keys or AWS owned keys carefully. Workspaces created with customer managed keys can't be converted to use AWS owned keys later (and vice versa). 5. (Optional) To add one or more tags to |
amazon-managed-prometheus-user-guide-008 | amazon-managed-prometheus-user-guide.pdf | 8 | using customer managed keys, there may be costs associated with keys from AWS Key Management Service. For more information about Amazon Managed Service for Prometheus encryption of data in the workspace, or how to create, manage, and use your own, customer managed key, see Encryption at rest. Note Workspaces created with customer managed keys cannot use AWS managed collectors for ingestion. Choose whether to use customer managed keys or AWS owned keys carefully. Workspaces created with customer managed keys can't be converted to use AWS owned keys later (and vice versa). 5. (Optional) To add one or more tags to the workspace, choose Add new tag. Then, in Key, enter a name for the tag. You can add an optional value for the tag in Value. To add another tag, choose Add new tag again. Create a workspace 19 Amazon Managed Service for Prometheus 6. Choose Create workspace. User Guide The workspace details page appears. This displays information including the status, ARN, workspace ID, and endpoint URLs for this workspace for both remote write and queries. The status returns CREATING until the workspace is ready. Wait until the status is ACTIVE before you move on to setting up your metric ingestion. Make note of the URLs that are displayed for Endpoint - remote write URL and Endpoint - query URL. You'll need them when you configure your Prometheus server to remote write metrics to this workspace and when you query those metrics. For information about how to ingest metrics into the workspace, see Ingest Prometheus metrics to the workspace. Configure your workspace You can configure your workspace for the following: • Define label sets and define limits on the active time series that match your defined label sets. A label set is a set of one or more labels, which are name/value pairs that help give context to time series metrics. By defining label sets and setting active time series limits, you can limit spikes in one tenant or source to affect only that tenant or source. For example, if you set a 1,000,000 active time series limit on the label set team=A env=prod, then if the number of ingested time series that match that label set exceed the limit, then only the time series that match the label set are throttled. This way, other tenants or metric sources are unaffected. For more information about labels in Prometheus, see Data Model. • Set a retention period to define the number of days for the data to be retained in the workspace. To configure your workspace 1. Open the Amazon Managed Service for Prometheus console at https:// console.aws.amazon.com/prometheus/. 2. In the upper left corner of the page, choose the menu icon and then choose All workspaces. 3. Choose the Workspace ID of the workspace. Configure your workspace 20 Amazon Managed Service for Prometheus User Guide 4. Choose the Workspace configurations tab. 5. 6. To set the retention period for the workspace, choose Edit in the Retention period section. Then specify the new retention period in days. The maximum is 1095 days (three years). To add or modify label sets and their active series limits, choose Edit in the Label sets section. Then do the following: a. b. (Optional) Enter a value in Default bucket limit to set a limit on the maximum number of active time series that can be ingested in the workspace, counting only time series that don’t match any defined label set. To define a label set, enter an active time series limit for the new label set under Active series limit. Then, enter a label and value for one label that will be used in the label set, and choose Add label. c. (Optional) To define another label set, choose Add another label set and repeat the previous steps. 7. When you are finished, choose Save changes. Edit a workspace alias You can edit a workspace to change its alias. To change the workspace alias using the AWS CLI, enter the following command. aws amp update-workspace-alias --workspace-id my-workspace-id --alias "new-alias" To edit a workspace using the Amazon Managed Service for Prometheus console 1. Open the Amazon Managed Service for Prometheus console at https:// console.aws.amazon.com/prometheus/. 2. In the upper left corner of the page, choose the menu icon and then choose All workspaces. 3. Choose the workspace ID of the workspace that you want to edit, and then choose Edit. 4. Enter a new alias for the workspace and then choose Save. Edit a workspace alias 21 Amazon Managed Service for Prometheus User Guide Find your Amazon Managed Service for Prometheus workspace details, including ARN You can find the details of your Amazon Managed Service for Prometheus workspace by using either the AWS console or the AWS CLI. Console To find your workspace details using the Amazon Managed |
amazon-managed-prometheus-user-guide-009 | amazon-managed-prometheus-user-guide.pdf | 9 | upper left corner of the page, choose the menu icon and then choose All workspaces. 3. Choose the workspace ID of the workspace that you want to edit, and then choose Edit. 4. Enter a new alias for the workspace and then choose Save. Edit a workspace alias 21 Amazon Managed Service for Prometheus User Guide Find your Amazon Managed Service for Prometheus workspace details, including ARN You can find the details of your Amazon Managed Service for Prometheus workspace by using either the AWS console or the AWS CLI. Console To find your workspace details using the Amazon Managed Service for Prometheus console 1. Open the Amazon Managed Service for Prometheus console at https:// console.aws.amazon.com/prometheus/. 2. In the upper left corner of the page, choose the menu icon and then choose All workspaces. 3. Choose the Workspace ID of the workspace. This will display details about your workspace, including: • Current status – The status of your workspace, for example Active, is displayed under Status. • ARN – The workspace ARN is displayed under ARN. • ID – The workspace ID is displayed under Workspace ID. • URLs – The console displays multiple URLs for the workspace, including the URLs for writing to or querying data from the workspace. Note By default, the URLs given are the IPv4 URLs. You can also use dualstack (IPv4 and IPv6 supported) URLs. These are the same, but are in the domain api.aws rather than the default amazonaws.com. For example, if you were to see the following (an IPv4 URL): https://aps-workspaces.us-east-1.amazonaws.com/workspaces/ws-abcd1234- ef56-7890-ab12-example/api/v1/remote_write You could create a dualstack (including support for IPv6), URL as follows: Find your workspace details 22 Amazon Managed Service for Prometheus User Guide https://aps-workspaces.us-east-1.api.aws/workspaces/ws-abcd1234- ef56-7890-ab12-example/api/v1/remote_write Below this section are tabs with information about rules, alert manager, logs, configuration, and tags. AWS CLI To find your workspace details using the AWS CLI The following command returns the details of the workspace. You must replace my- workspace-id with the workspace ID of the workspace for which you want the details. aws amp describe-workspace --workspace-id my-workspace-id This returns details about your workspace, including: • Current status – The status of your workspace, for example ACTIVE, is returned in the statusCode property. • ARN – The workspace ARN is returned in the arn property. • URLs – The AWS CLI returns the base URL for the workspace in the prometheusEndpoint property. Note By default, the URL returned is the IPv4 URL. You can also use a dualstack (IPv4 and IPv6 supported) URL in the domain api.aws rather than the default amazonaws.com. For example, if you were to see the following (an IPv4 URL): https://aps-workspaces.us-east-1.amazonaws.com/workspaces/ws-abcd1234- ef56-7890-ab12-example/ You could create a dualstack (including support for IPv6), URL as follows: https://aps-workspaces.us-east-1.api.aws/workspaces/ws-abcd1234-ef56-7890- ab12-example/ Find your workspace details 23 Amazon Managed Service for Prometheus User Guide You can also create the remote write and query URLs for the workspace, by adding / api/v1/remote_write or /api/v1/query, respectively. Delete an Amazon Managed Service for Prometheus workspace Deleting a workspace deletes the data that has been ingested into it. Note Deleting an Amazon Managed Service for Prometheus workspace does not automatically delete any AWS managed collectors that are scraping metrics and sending them to the workspace. For more information, see Find and delete scrapers. To delete a workspace using the AWS CLI Use the following command: aws amp delete-workspace --workspace-id my-workspace-id To delete a workspace using the Amazon Managed Service for Prometheus console 1. Open the Amazon Managed Service for Prometheus console at https:// console.aws.amazon.com/prometheus/. 2. In the upper left corner of the page, choose the menu icon and then choose All workspaces. 3. Choose the workspace ID of the workspace that you want to delete, and then choose Delete. 4. Enter delete in the confirmation box, and choose Delete. Delete a workspace 24 Amazon Managed Service for Prometheus User Guide Ingest metrics to your Amazon Managed Service for Prometheus workspace Metrics must be ingested into your Amazon Managed Service for Prometheus workspace before you can query or alert on those metrics. This section explains how to set up the ingestion of metrics into your workspace. Note Metrics ingested into a workspace are stored for 150 days by default, and are then automatically deleted. This length is controlled by an adjustable quota. There are two methods of ingesting metrics into your Amazon Managed Service for Prometheus workspace. • Using an AWS managed collector – Amazon Managed Service for Prometheus provides a fully-managed, agentless scraper to automatically scrape metrics from your Amazon Elastic Kubernetes Service (Amazon EKS) clusters. Scraping automatically pulls the metrics from Prometheus-compatible endpoints. • Using a customer managed collector – You have many options for managing your own collector. Two of the most common collectors to use are installing your own instance of Prometheus, running in agent mode, or using |
amazon-managed-prometheus-user-guide-010 | amazon-managed-prometheus-user-guide.pdf | 10 | automatically deleted. This length is controlled by an adjustable quota. There are two methods of ingesting metrics into your Amazon Managed Service for Prometheus workspace. • Using an AWS managed collector – Amazon Managed Service for Prometheus provides a fully-managed, agentless scraper to automatically scrape metrics from your Amazon Elastic Kubernetes Service (Amazon EKS) clusters. Scraping automatically pulls the metrics from Prometheus-compatible endpoints. • Using a customer managed collector – You have many options for managing your own collector. Two of the most common collectors to use are installing your own instance of Prometheus, running in agent mode, or using AWS Distro for OpenTelemetry. These are both described in detail in the following sections. Collectors send metrics to Amazon Managed Service for Prometheus using Prometheus remote write functionality. You can directly send metrics to Amazon Managed Service for Prometheus by using Prometheus remote write in your own application. For more details about directly using remote write, and remote write configurations, see remote_write in the Prometheus documentation. Topics • Ingest metrics with AWS managed collectors • Customer managed collectors 25 Amazon Managed Service for Prometheus User Guide Ingest metrics with AWS managed collectors A common use case for Amazon Managed Service for Prometheus is to monitor Kubernetes clusters managed by Amazon Elastic Kubernetes Service (Amazon EKS). Kubernetes clusters, and many applications that run within Amazon EKS, automatically export their metrics for Prometheus- compatible scrapers to access. Note Amazon EKS exposes API server metrics, kube-controller-manager metrics, and kube-scheduler metrics in a cluster. Many other technologies and applications running in Kubernetes environments provide Prometheus-compatible metrics. For a list of well- documented exporters, see Exporters and integrations in the Prometheus documentation. Amazon Managed Service for Prometheus provides a fully managed, agent less scraper, or collector, that automatically discovers and pulls Prometheus-compatible metrics. You don't have to manage, install, patch, or maintain agents or scrapers. An Amazon Managed Service for Prometheus collector provides reliable, stable, highly available, automatically scaled collection of metrics for your Amazon EKS cluster. Amazon Managed Service for Prometheus managed collectors work with Amazon EKS clusters, including EC2 and Fargate. An Amazon Managed Service for Prometheus collector creates an Elastic Network Interface (ENI) per subnet specified when creating the scraper. The collector scrapes the metrics through these ENIs, and uses remote_write to push the data to your Amazon Managed Service for Prometheus workspace using a VPC endpoint. The scraped data never travels on the public internet. The following topics provide more information about how to use an Amazon Managed Service for Prometheus collector in your Amazon EKS cluster, and about the collected metrics. Topics • Using an AWS managed collector • What are Prometheus-compatible metrics? Using an AWS managed collector To use an Amazon Managed Service for Prometheus collector, you must create a scraper that discovers and pulls metrics in your Amazon EKS cluster. AWS managed collectors 26 Amazon Managed Service for Prometheus User Guide • You can create a scraper as part of your Amazon EKS cluster creation. For more information about creating an Amazon EKS cluster, including creating a scraper, see Creating an Amazon EKS cluster in the Amazon EKS User Guide. • You can create your own scraper, programmatically with the AWS API or by using the AWS CLI. An Amazon Managed Service for Prometheus collector scrapes metrics that are Prometheus- compatible. For more information about Prometheus compatible metrics, see What are Prometheus-compatible metrics?. Amazon EKS clusters expose metrics for the API server. Amazon EKS clusters that are Kubernetes version 1.28 or above also expose metrics for the kube- scheduler and kube-controller-manager. For more information, see Fetch control plane raw metrics in Prometheus format in the Amazon EKS User Guide. Note Scraping metrics from a cluster may incur charges for network usage. One way to optimize these costs is to configure your /metrics endpoint to compress the provided metrics (for example, with gzip), reducing the data that must be moved across the network. How to do this depends on the application or library providing the metrics. Some libraries gzip by default. The following topics describe how to create, manage, and configure scrapers. Topics • Create a scraper • Configuring your Amazon EKS cluster • Find and delete scrapers • Scraper configuration • Troubleshooting scraper configuration • Scraper limitations Create a scraper An Amazon Managed Service for Prometheus collector consists of a scraper that discovers and collects metrics from an Amazon EKS cluster. Amazon Managed Service for Prometheus manages Using a managed collector 27 Amazon Managed Service for Prometheus User Guide the scraper for you, giving you the scalability, security, and reliability that you need, without having to manage any instances, agents, or scrapers yourself. There are three ways to create a scraper: • A scraper is automatically created for you when you create an Amazon EKS cluster through the |
amazon-managed-prometheus-user-guide-011 | amazon-managed-prometheus-user-guide.pdf | 11 | Scraper configuration • Troubleshooting scraper configuration • Scraper limitations Create a scraper An Amazon Managed Service for Prometheus collector consists of a scraper that discovers and collects metrics from an Amazon EKS cluster. Amazon Managed Service for Prometheus manages Using a managed collector 27 Amazon Managed Service for Prometheus User Guide the scraper for you, giving you the scalability, security, and reliability that you need, without having to manage any instances, agents, or scrapers yourself. There are three ways to create a scraper: • A scraper is automatically created for you when you create an Amazon EKS cluster through the Amazon EKS console and choose to turn on Prometheus metrics. • You can create a scraper from the Amazon EKS console for an existing cluster. Open the cluster in the Amazon EKS console, then, on the Observability tab, choose Add scraper. For more details on the available settings, see Turn on Prometheus metrics in the Amazon EKS User Guide. • You can create a scraper using either the AWS API or the AWS CLI. These options are described in the following procedure. There are a few prerequisites for creating your own scraper: • You must have an Amazon EKS cluster created. • Your Amazon EKS cluster must have cluster endpoint access control set to include private access. It can include private and public, but must include private. • The Amazon VPC in which the Amazon EKS cluster resides must have DNS enabled. Note The cluster will be associated with the scraper by its Amazon resource name (ARN). If you delete a cluster, and then create a new one with the same name, the ARN will be reused for the new cluster. Because of this, the scraper will attempt to collect metrics for the new cluster. You delete scrapers separately from deleting the cluster. AWS API To create a scraper using the AWS API Use the CreateScraper API operation to create a scraper with the AWS API. The following example creates a scraper in the us-west-2 Region. You need to replace the AWS account, Using a managed collector 28 Amazon Managed Service for Prometheus User Guide workspace, security, and Amazon EKS cluster information with your own IDs, and provide the configuration to use for your scraper. Note The security group and subnets should be set to the security group and subnets for the cluster to which you are connecting. You must include at least two subnets, in at least two availability zones. The scrapeConfiguration is a Prometheus configuration YAML file that is base64 encoded. You can download a general purpose configuration with the GetDefaultScraperConfiguration API operation. For more information about the format of the scrapeConfiguration, see Scraper configuration. POST /scrapers HTTP/1.1 Content-Length: 415 Authorization: AUTHPARAMS X-Amz-Date: 20201201T193725Z User-Agent: aws-cli/1.18.147 Python/2.7.18 Linux/5.4.58-37.125.amzn2int.x86_64 botocore/1.18.6 { "alias": "myScraper", "destination": { "ampConfiguration": { "workspaceArn": "arn:aws:aps:us-west-2:account-id:workspace/ ws-workspace-id" } }, "source": { "eksConfiguration": { "clusterArn": "arn:aws:eks:us-west-2:account-id:cluster/cluster-name", "securityGroupIds": ["sg-security-group-id"], "subnetIds": ["subnet-subnet-id-1", "subnet-subnet-id-2"] } }, "scrapeConfiguration": { "configurationBlob": <base64-encoded-blob> } } Using a managed collector 29 Amazon Managed Service for Prometheus User Guide AWS CLI To create a scraper using the AWS CLI Use the create-scraper command to create a scraper with the the AWS CLI. The following example creates a scraper in the us-west-2 Region. You need to replace the AWS account, workspace, security, and Amazon EKS cluster information with your own IDs, and provide the configuration to use for your scraper. Note The security group and subnets should be set to the security group and subnets for the cluster to which you are connecting. You must include at least two subnets, in at least two availability zones. The scrape-configuration is a Prometheus configuration YAML file that is base64 encoded. You can download a general purpose configuration with the get-default- scraper-configuration command. For more information about the format of the scrape- configuration, see Scraper configuration. aws amp create-scraper \ --source eksConfiguration="{clusterArn='arn:aws:eks:us-west-2:account- id:cluster/cluster-name', securityGroupIds=['sg-security-group- id'],subnetIds=['subnet-subnet-id-1', 'subnet-subnet-id-2']}" \ --scrape-configuration configurationBlob=<base64-encoded-blob> \ --destination ampConfiguration="{workspaceArn='arn:aws:aps:us-west-2:account- id:workspace/ws-workspace-id'}" The following is a full list of the scraper operations that you can use with the AWS API: • Create a scraper with the CreateScraper API operation. • List your existing scrapers with the ListScrapers API operation. • Update the alias, configuration, or destination of a scraper with the UpdateScraper API operation. • Delete a scraper with the DeleteScraper API operation. • Get more details about a scraper with the DescribeScraper API operation. Using a managed collector 30 Amazon Managed Service for Prometheus User Guide • Get a general purpose configuration for scrapers with the GetDefaultScraperConfiguration API operation. Note The Amazon EKS cluster that you are scraping must be configured to allow Amazon Managed Service for Prometheus to access the metrics. The next topic describes how to configure your cluster. Cross-account setup To create a scraper in a cross-account setup when your Amazon EKS cluster from |
amazon-managed-prometheus-user-guide-012 | amazon-managed-prometheus-user-guide.pdf | 12 | scraper with the UpdateScraper API operation. • Delete a scraper with the DeleteScraper API operation. • Get more details about a scraper with the DescribeScraper API operation. Using a managed collector 30 Amazon Managed Service for Prometheus User Guide • Get a general purpose configuration for scrapers with the GetDefaultScraperConfiguration API operation. Note The Amazon EKS cluster that you are scraping must be configured to allow Amazon Managed Service for Prometheus to access the metrics. The next topic describes how to configure your cluster. Cross-account setup To create a scraper in a cross-account setup when your Amazon EKS cluster from which you want to collect metrics is in a different account from the Amazon Managed Service for Prometheus collector, use the procedure below. For example, when you have two accounts, the first source account account_id_source where the Amazon EKS is located, and a second target account account_id_target where the Amazon Managed Service for Prometheus workspace resides. To create a scraper in a cross-account setup 1. In the source account, create a role arn:aws:iam::account_id_source:role/Source and add the following trust policy. { "Effect": "Allow", "Principal": { "Service": [ "scraper.aps.amazonaws.com" ] }, "Action": "sts:AssumeRole", "Condition": { "ArnEquals": { "aws:SourceArn": "scraper_ARN" }, "StringEquals": { "AWS:SourceAccount": "account_id" } Using a managed collector 31 Amazon Managed Service for Prometheus User Guide } } 2. On every combination of source (Amazon EKS cluster) and target (Amazon Managed Service for Prometheus workspace), you need to create a role arn:aws:iam::account_id_target:role/Target and add the following trust policy with permissions for AmazonPrometheusRemoteWriteAccess. { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::account_id_source:role/Source" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "sts:ExternalId": "scraper_ARN" } } } 3. Create a scraper with the --role-configuration option. aws amp create-scraper \ --source eksConfiguration="{clusterArn='arn:aws:eks:us-west-2:account- id_source:cluster/xarw,subnetIds=[subnet-subnet-id]}" \ --scrape-configuration configurationBlob=<base64-encoded-blob> \ --destination ampConfiguration="{workspaceArn='arn:aws:aps:us-west-2:account- id_target:workspace/ws-workspace-id'}"\ --role-configuration '{"sourceRoleArn":"arn:aws:iam::account-id_source:role/ Source", "targetRoleArn":"arn:aws:iam::account-id_target:role/Target"}' 4. Validate the scraper creation. aws amp list-scrapers { "scrapers": [ { "scraperId": "scraper-id", Using a managed collector 32 Amazon Managed Service for Prometheus User Guide "arn": "arn:aws:aps:us-west-2:account_id_source:scraper/scraper-id", "roleArn": "arn:aws:iam::account_id_source:role/aws-service-role/ scraper.aps.amazonaws.com/ AWSServiceRoleForAmazonPrometheusScraperInternal_cc319052-41a3-4", "status": { "statusCode": "ACTIVE" }, "createdAt": "2024-10-29T16:37:58.789000+00:00", "lastModifiedAt": "2024-10-29T16:55:17.085000+00:00", "tags": {}, "source": { "eksConfiguration": { "clusterArn": "arn:aws:eks:us-west-2:account_id_source:cluster/ xarw", "securityGroupIds": [ "sg-security-group-id", "sg-security-group-id" ], "subnetIds": [ "subnet-subnet_id" ] } }, "destination": { "ampConfiguration": { "workspaceArn": "arn:aws:aps:us- west-2:account_id_target:workspace/ws-workspace-id" } } } ] } Changing between RoleConfiguration and service-linked role When you want to switch back to a service-linked role instead of the RoleConfiguration to write to an Amazon Managed Service for Prometheus workspace, you must update the UpdateScraper and provide a workspace in the same account as the scraper without the Using a managed collector 33 Amazon Managed Service for Prometheus User Guide RoleConfiguration. The RoleConfiguration will be removed from the scraper and the service-linked role will be used. When you are changing workspaces in the same account as the scraper and you want to continue using the RoleConfiguration, you must again provide the RoleConfiguration on UpdateScraper. Creating scraper for workspaces enabled with customer managed keys To create a scraper for ingesting metrics into a Amazon Managed Service for Prometheus workspace with customer managed keys, use the --role-configuration with both the source and target set to the same account. aws amp create-scraper \ --source eksConfiguration="{clusterArn='arn:aws:eks:us-west-2:account-id:cluster/ xarw,subnetIds=[subnet-subnet_id]}" \ --scrape-configuration configurationBlob=<base64-encoded-blob> \ --destination ampConfiguration="{workspaceArn='arn:aws:aps:us-west-2:account- id:workspace/ws-workspace-id'}"\ --role-configuration '{"sourceRoleArn":"arn:aws:iam::account_id:role/Source", "targetRoleArn":"arn:aws:iam::account_id:role/Target"}' Common errors when creating scrapers The following are the most common issues when attempting to create a new scraper. • Required AWS resources don't exist. The security group, subnets, and Amazon EKS cluster specified must exist. • Insufficient IP address space. You must have at least one IP address available in each subnet that you pass into the CreateScraper API. Configuring your Amazon EKS cluster Your Amazon EKS cluster must be configured to allow the scraper to access metrics. There are two options for this configuration: • Use Amazon EKS access entries to automatically provide Amazon Managed Service for Prometheus collectors access to your cluster. • Manually configure your Amazon EKS cluster for managed metric scraping. Using a managed collector 34 Amazon Managed Service for Prometheus User Guide The following topics describe each of these in more detail. Configure Amazon EKS for scraper access with access entries Using access entries for Amazon EKS is the easiest way to give Amazon Managed Service for Prometheus access to scrape metrics from your cluster. The Amazon EKS cluster that you are scraping must be configured to allow API authentication. The cluster authentication mode must be set to either API or API_AND_CONFIG_MAP. This is viewable in the Amazon EKS console on the Access configuration tab of the cluster details. For more information, see Allowing IAM roles or users access to Kubernetes object on your Amazon EKS cluster in the Amazon EKS User Guide. You can create the scraper when creating the cluster, or after creating the cluster: • When creating a cluster – You can configure this access when you create an |
amazon-managed-prometheus-user-guide-013 | amazon-managed-prometheus-user-guide.pdf | 13 | from your cluster. The Amazon EKS cluster that you are scraping must be configured to allow API authentication. The cluster authentication mode must be set to either API or API_AND_CONFIG_MAP. This is viewable in the Amazon EKS console on the Access configuration tab of the cluster details. For more information, see Allowing IAM roles or users access to Kubernetes object on your Amazon EKS cluster in the Amazon EKS User Guide. You can create the scraper when creating the cluster, or after creating the cluster: • When creating a cluster – You can configure this access when you create an Amazon EKS cluster through the Amazon EKS console (follow the instructions to create a scraper as part of the cluster), and an access entry policy will automatically be created, giving Amazon Managed Service for Prometheus access to the cluster metrics. • Adding after a cluster is created – if your Amazon EKS cluster already exists, then set the authentication mode to either API or API_AND_CONFIG_MAP, and any scrapers you create through the Amazon Managed Service for Prometheus API or CLI or through the Amazon EKS console will automatically have the correct access entry policy created for you, and the scrapers will have access to your cluster. Access entry policy created When you create a scraper and let Amazon Managed Service for Prometheus generate an access entry policy for you, it generates the following policy. For more information about access entries, see Allowing IAM roles or users access to Kubernetes in the Amazon EKS User Guide. { "rules": [ { "effect": "allow", "apiGroups": [ "" ], "resources": [ "nodes", Using a managed collector 35 Amazon Managed Service for Prometheus User Guide "nodes/proxy", "nodes/metrics", "services", "endpoints", "pods", "ingresses", "configmaps" ], "verbs": [ "get", "list", "watch" ] }, { "effect": "allow", "apiGroups": [ "extensions", "networking.k8s.io" ], "resources": [ "ingresses/status", "ingresses" ], "verbs": [ "get", "list", "watch" ] }, { "effect": "allow", "apiGroups": [ "metrics.eks.amazonaws.com" ], "resources": [ "kcm/metrics", "ksh/metrics" ], "verbs": [ "get" ] }, { Using a managed collector 36 Amazon Managed Service for Prometheus User Guide "effect": "allow", "nonResourceURLs": [ "/metrics" ], "verbs": [ "get" ] } ] } Manually configuring Amazon EKS for scraper access If you prefer to use the aws-auth ConfigMap to control access to your kubernetes cluster, you can still give Amazon Managed Service for Prometheus scrapers access to your metrics. The following steps will give Amazon Managed Service for Prometheus access to scrape metrics from your Amazon EKS cluster. Note For more information about ConfigMap and access entries, see Allowing IAM roles or users access to Kubernetes in the Amazon EKS User Guide. This procedure uses kubectl and the AWS CLI. For information about installing kubectl, see Installing kubectl in the Amazon EKS User Guide. To manually configure your Amazon EKS cluster for managed metric scraping 1. Create a file, called clusterrole-binding.yml, with the following text: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: aps-collector-role rules: - apiGroups: [""] resources: ["nodes", "nodes/proxy", "nodes/metrics", "services", "endpoints", "pods", "ingresses", "configmaps"] verbs: ["describe", "get", "list", "watch"] - apiGroups: ["extensions", "networking.k8s.io"] Using a managed collector 37 Amazon Managed Service for Prometheus User Guide resources: ["ingresses/status", "ingresses"] verbs: ["describe", "get", "list", "watch"] - nonResourceURLs: ["/metrics"] verbs: ["get"] - apiGroups: ["metrics.eks.amazonaws.com"] resources: ["kcm/metrics", "ksh/metrics"] verbs: ["get"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: aps-collector-user-role-binding subjects: - kind: User name: aps-collector-user apiGroup: rbac.authorization.k8s.io roleRef: kind: ClusterRole name: aps-collector-role apiGroup: rbac.authorization.k8s.io 2. Run the following command in your cluster: kubectl apply -f clusterrole-binding.yml This will create the cluster role binding and rule. This example uses aps-collector-role as the role name, and aps-collector-user as the user name. 3. The following command gives you information about the scraper with the ID scraper-id. This is the scraper that you created using the command in the previous section. aws amp describe-scraper --scraper-id scraper-id 4. From the results of the describe-scraper, find the roleArn.This will have the following format: arn:aws:iam::account-id:role/aws-service-role/scraper.aps.amazonaws.com/ AWSServiceRoleForAmazonPrometheusScraper_unique-id Amazon EKS requires a different format for this ARN. You must adjust the format of the returned ARN to be used in the next step. Edit it to match this format: Using a managed collector 38 Amazon Managed Service for Prometheus User Guide arn:aws:iam::account-id:role/AWSServiceRoleForAmazonPrometheusScraper_unique-id For example, this ARN: arn:aws:iam::111122223333:role/aws-service-role/scraper.aps.amazonaws.com/ AWSServiceRoleForAmazonPrometheusScraper_1234abcd-56ef-7 Must be rewritten as: arn:aws:iam::111122223333:role/ AWSServiceRoleForAmazonPrometheusScraper_1234abcd-56ef-7 5. Run the following command in your cluster, using the modified roleArn from the previous step, as well as your cluster name and region.: eksctl create iamidentitymapping --cluster cluster-name --region region-id -- arn roleArn --username aps-collector-user This allows the scraper to access the cluster using the role and user you created in the clusterrole-binding.yml file. Find and delete scrapers You can use the AWS API or the AWS CLI to list the scrapers in your account or to delete them. Note Make sure that you are using the latest version of the AWS CLI |
amazon-managed-prometheus-user-guide-014 | amazon-managed-prometheus-user-guide.pdf | 14 | Must be rewritten as: arn:aws:iam::111122223333:role/ AWSServiceRoleForAmazonPrometheusScraper_1234abcd-56ef-7 5. Run the following command in your cluster, using the modified roleArn from the previous step, as well as your cluster name and region.: eksctl create iamidentitymapping --cluster cluster-name --region region-id -- arn roleArn --username aps-collector-user This allows the scraper to access the cluster using the role and user you created in the clusterrole-binding.yml file. Find and delete scrapers You can use the AWS API or the AWS CLI to list the scrapers in your account or to delete them. Note Make sure that you are using the latest version of the AWS CLI or SDK. The latest version provides you with the latest features and functionality, as well as security updates. Alternatively, use AWS Cloudshell, which provides an always up-to-date command line experience, automatically. To list all the scrapers in your account, use the ListScrapers API operation. Alternatively, with the AWS CLI, call: Using a managed collector 39 Amazon Managed Service for Prometheus User Guide aws amp list-scrapers ListScrapers returns all of the scrapers in your account, for example: { "scrapers": [ { "scraperId": "s-1234abcd-56ef-7890-abcd-1234ef567890", "arn": "arn:aws:aps:us-west-2:123456789012:scraper/s-1234abcd-56ef-7890- abcd-1234ef567890", "roleArn": "arn:aws:iam::123456789012:role/aws-service-role/ AWSServiceRoleForAmazonPrometheusScraper_1234abcd-2931", "status": { "statusCode": "DELETING" }, "createdAt": "2023-10-12T15:22:19.014000-07:00", "lastModifiedAt": "2023-10-12T15:55:43.487000-07:00", "tags": {}, "source": { "eksConfiguration": { "clusterArn": "arn:aws:eks:us-west-2:123456789012:cluster/my- cluster", "securityGroupIds": [ "sg-1234abcd5678ef90" ], "subnetIds": [ "subnet-abcd1234ef567890", "subnet-1234abcd5678ab90" ] } }, "destination": { "ampConfiguration": { "workspaceArn": "arn:aws:aps:us-west-2:123456789012:workspace/ ws-1234abcd-5678-ef90-ab12-cdef3456a78" } } } ] } Using a managed collector 40 Amazon Managed Service for Prometheus User Guide To delete a scraper, find the scraperId for the scraper that you want to delete, using the ListScrapers operation, and then use the DeleteScraper operation to delete it. Alternatively, with the AWS CLI, call: aws amp delete-scraper --scraper-id scraperId Scraper configuration You can control how your scraper discovers and collects metrics with a Prometheus-compatible scraper configuration. For example, you can change the interval that metrics are sent to the workspace. You can also use relabeling to dynamically rewrite the labels of a metric. The scraper configuration is a YAML file that is part of the definition of the scraper. When a new scraper is created, you specify a configuration by providing a base64 encoded YAML file in the API call. You can download a general purpose configuration file with the GetDefaultScraperConfiguration operation in the Amazon Managed Service for Prometheus API. To modify the configuration of a scraper, you can use the UpdateScraper operation. If you need to update the source of the metrics (for example, to a different Amazon EKS cluster), you must delete the scraper and recreate it with the new source. Supported configuration For information about the scraper configuration format, including a detailed breakdown of the possible values, see Configuration in the Prometheus documentation. The global configuration options, and <scrape_config> options describe the most commonly needed options. Because Amazon EKS is the only supported service, the only service discovery config (<*_sd_config>) supported is the <kubernetes_sd_config>. The complete list of config sections allowed: • <global> • <scrape_config> • <static_config> • <relabel_config> Using a managed collector 41 Amazon Managed Service for Prometheus • <metric_relabel_configs> • <kubernetes_sd_config> User Guide Limitations within these sections are listed after the sample configuration file. Sample configuration file The following is a sample YAML configuration file with a 30 second scrape interval. This sample includes support for the kube API server metrics, as well as kube-controller-manager and kube- scheduler metrics. For more information, see Fetch control plane raw metrics in Prometheus format in the Amazon EKS User Guide. global: scrape_interval: 30s external_labels: clusterArn: apiserver-test-2 scrape_configs: - job_name: pod_exporter kubernetes_sd_configs: - role: pod - job_name: cadvisor scheme: https authorization: type: Bearer credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token kubernetes_sd_configs: - role: node relabel_configs: - action: labelmap regex: __meta_kubernetes_node_label_(.+) - replacement: kubernetes.default.svc:443 target_label: __address__ - source_labels: [__meta_kubernetes_node_name] regex: (.+) target_label: __metrics_path__ replacement: /api/v1/nodes/$1/proxy/metrics/cadvisor # apiserver metrics - scheme: https authorization: type: Bearer credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token job_name: kubernetes-apiservers Using a managed collector 42 User Guide Amazon Managed Service for Prometheus kubernetes_sd_configs: - role: endpoints relabel_configs: - action: keep regex: default;kubernetes;https source_labels: - __meta_kubernetes_namespace - __meta_kubernetes_service_name - __meta_kubernetes_endpoint_port_name # kube proxy metrics - job_name: kube-proxy honor_labels: true kubernetes_sd_configs: - role: pod relabel_configs: - action: keep source_labels: - __meta_kubernetes_namespace - __meta_kubernetes_pod_name separator: '/' regex: 'kube-system/kube-proxy.+' - source_labels: - __address__ action: replace target_label: __address__ regex: (.+?)(\\:\\d+)? replacement: $1:10249 # Scheduler metrics - job_name: 'ksh-metrics' kubernetes_sd_configs: - role: endpoints metrics_path: /apis/metrics.eks.amazonaws.com/v1/ksh/container/metrics scheme: https bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token relabel_configs: - source_labels: - __meta_kubernetes_namespace - __meta_kubernetes_service_name - __meta_kubernetes_endpoint_port_name action: keep regex: default;kubernetes;https # Controller Manager metrics - job_name: 'kcm-metrics' kubernetes_sd_configs: Using a managed collector 43 Amazon Managed Service for Prometheus - role: endpoints User Guide metrics_path: /apis/metrics.eks.amazonaws.com/v1/kcm/container/metrics scheme: https bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token relabel_configs: - source_labels: - __meta_kubernetes_namespace - __meta_kubernetes_service_name - __meta_kubernetes_endpoint_port_name action: keep regex: default;kubernetes;https The following are limitations specific to AWS managed collectors: • Scrape interval – The scraper config can't specify a scrape interval of less than 30 seconds. • Targets |
amazon-managed-prometheus-user-guide-015 | amazon-managed-prometheus-user-guide.pdf | 15 | $1:10249 # Scheduler metrics - job_name: 'ksh-metrics' kubernetes_sd_configs: - role: endpoints metrics_path: /apis/metrics.eks.amazonaws.com/v1/ksh/container/metrics scheme: https bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token relabel_configs: - source_labels: - __meta_kubernetes_namespace - __meta_kubernetes_service_name - __meta_kubernetes_endpoint_port_name action: keep regex: default;kubernetes;https # Controller Manager metrics - job_name: 'kcm-metrics' kubernetes_sd_configs: Using a managed collector 43 Amazon Managed Service for Prometheus - role: endpoints User Guide metrics_path: /apis/metrics.eks.amazonaws.com/v1/kcm/container/metrics scheme: https bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token relabel_configs: - source_labels: - __meta_kubernetes_namespace - __meta_kubernetes_service_name - __meta_kubernetes_endpoint_port_name action: keep regex: default;kubernetes;https The following are limitations specific to AWS managed collectors: • Scrape interval – The scraper config can't specify a scrape interval of less than 30 seconds. • Targets – Targets in the static_config must be specified as IP addresses. • DNS resolution – Related to the target name, the only server name that is recognized in this config is the Kubernetes api server, kubernetes.default.svc. All other machines names must be specified by IP address. • Authorization – Omit if no authorization is needed. If it is needed, the authorization must be Bearer, and must point to the file /var/run/secrets/kubernetes.io/serviceaccount/ token. In other words, if used, the authorization section must look like the following: authorization: type: Bearer credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token Note type: Bearer is the default, so can be omitted. Troubleshooting scraper configuration Amazon Managed Service for Prometheus collectors automatically discover and scrape metrics. But how can you troubleshoot when you don't see a metric you expect to see in your Amazon Managed Service for Prometheus workspace? Using a managed collector 44 Amazon Managed Service for Prometheus User Guide The up metric is a helpful tool. For each endpoint that an Amazon Managed Service for Prometheus collector discovers, it automatically vends this metric. There are three states of this metric that can help you to troubleshoot what is happening within the collector. • up is not present – If there is no up metric present for an endpoint, then that means that the collector was not able to find the endpoint. If you are sure that the endpoint exists, there are several reasons why the collector might not be able to find it. • You might need to adjust the scrape configuration. The discovery relabel_config might need to be adjusted. • There could be a problem with the role used for discovery. • The Amazon VPC used by the Amazon EKS cluster might not have DNS enabled, which would keep the collector from finding the endpoint. • up is present, but is always 0 – If up is present, but 0, then the collector is able to discover the endpoint, but can't find any Prometheus-compatible metrics. In this case, you might try using a curl command against the endpoint directly. You can validate that you have the details correct, for example, the protocol (http or https), the endpoint, or port that you are using. You can also check that the endpoint is responding with a valid 200 response, and follows the Prometheus format. Finally, the body of the response can't be larger than the maximum allowed size. (For limits on AWS managed collectors, see the following section.) • up is present and greater than 0 – If up is present, and is greater than 0, then metrics are being sent to Amazon Managed Service for Prometheus. Validate that you are looking for the correct metrics in Amazon Managed Service for Prometheus (or your alternate dashboard, such as Amazon Managed Grafana). You can use curl again to check for expected data in your /metrics endpoint. Also check that you haven't exceeded other limits, such as the number of endpoints per scraper. You can check the number of metrics endpoints being scraped by checking the count of up metrics, using count(up). Scraper limitations There are few limitations to the fully managed scrapers provided by Amazon Managed Service for Prometheus. Using a managed collector 45 Amazon Managed Service for Prometheus User Guide • Region – Your EKS cluster, managed scraper, and Amazon Managed Service for Prometheus workspace must all be in the same AWS Region. • Account – Your EKS cluster, managed scraper, and Amazon Managed Service for Prometheus workspace must all be in the same AWS account. • Collectors – You can have a maximum of 10 Amazon Managed Service for Prometheus scrapers per region per account. Note You can request an increase to this limit by requesting a quota increase. • Metrics response – The body of a response from any one /metrics endpoint request cannot be more than 50 megabytes (MB). • Endpoints per scraper – A scraper can scrape a maximum of 30,000 /metrics endpoints. • Scrape interval – The scraper config can't specify a scrape interval of less than 30 seconds. What are Prometheus-compatible metrics? To scrape Prometheus metrics from your applications and infrastructure for use in Amazon Managed Service for Prometheus, they must instrument and expose Prometheus-compatible |
amazon-managed-prometheus-user-guide-016 | amazon-managed-prometheus-user-guide.pdf | 16 | scrapers per region per account. Note You can request an increase to this limit by requesting a quota increase. • Metrics response – The body of a response from any one /metrics endpoint request cannot be more than 50 megabytes (MB). • Endpoints per scraper – A scraper can scrape a maximum of 30,000 /metrics endpoints. • Scrape interval – The scraper config can't specify a scrape interval of less than 30 seconds. What are Prometheus-compatible metrics? To scrape Prometheus metrics from your applications and infrastructure for use in Amazon Managed Service for Prometheus, they must instrument and expose Prometheus-compatible metrics from Prometheus-compatible /metrics endpoints. You can implement your own metrics, but you don't have to. Kubernetes (including Amazon EKS) and many other libraries and services implement these metrics directly. When metrics in Amazon EKS are exported to a Prometheus-compatible endpoint, you can have those metrics automatically scraped by the Amazon Managed Service for Prometheus collector. For more information, see the following topics: • For more information about existing libraries and services that export metrics as Prometheus metrics, see Exporters and integrations in the Prometheus documentation. • For more information about exporting Prometheus-compatible metrics from your own code, see Writing exporters in the Prometheus documentation. • For more information about how to set up an Amazon Managed Service for Prometheus collector to scrape metrics from your Amazon EKS clusters automatically, see Using an AWS managed collector. Prometheus-compatible metrics 46 Amazon Managed Service for Prometheus User Guide Customer managed collectors This section contains information about ingesting data by setting up your own collectors that send metrics to Amazon Managed Service for Prometheus using Prometheus remote write. When you use your own collectors to send metrics to Amazon Managed Service for Prometheus, you are responsible for securing your metrics and making sure that the ingestion process meets your availability needs. Most customer managed collectors use one of the following tools: • AWS Distro for OpenTelemetry (ADOT) – ADOT is a fully supported, secure, production-ready open source distribution of OpenTelemetry that provides agents to collect metrics. You can use ADOT to collect metrics and send them to your Amazon Managed Service for Prometheus workspace. For more information about the ADOT Collector, see AWS Distro for OpenTelemetry. • Prometheus agent – You can set up your own instance of the open source Prometheus server, running as an agent, to collect metrics and forward them to your Amazon Managed Service for Prometheus workspace. The following topics describe using both of these tools and include general information about setting up your own collectors. Topics • Secure the ingestion of your metrics • Using AWS Distro for OpenTelemetry as a collector • Using a Prometheus instance as a collector • Set up Amazon Managed Service for Prometheus for high availability data Secure the ingestion of your metrics Amazon Managed Service for Prometheus provides ways of helping you secure the ingestion of your metrics. Using AWS PrivateLink with Amazon Managed Service for Prometheus The network traffic of ingesting the metrics into Amazon Managed Service for Prometheus can be done over a public internet endpoint, or by a VPC endpoint through AWS PrivateLink. Using AWS Customer managed collectors 47 Amazon Managed Service for Prometheus User Guide PrivateLink ensures that the network traffic from your VPCs is secured within the AWS network without going over the public internet. To create an AWS PrivateLink VPC endpoint for Amazon Managed Service for Prometheus, see Using Amazon Managed Service for Prometheus with interface VPC endpoints. Authentication and authorization AWS Identity and Access Management (IAM) is a web service that helps you securely control access to AWS resources. You use IAM to control who is authenticated (signed in) and authorized (has permissions) to use resources. Amazon Managed Service for Prometheus integrates with IAM to help you keep your data secure. When you set up Amazon Managed Service for Prometheus, you need to create some IAM roles that enable it to ingest metrics from Prometheus servers, and that enable Grafana servers to query the metrics that are stored in your Amazon Managed Service for Prometheus workspaces. For more information about IAM, see What is IAM?. Another AWS security feature that can help you set up Amazon Managed Service for Prometheus is the AWS Signature Version 4 signing process (AWS SigV4). Signature Version 4 is the process to add authentication information to AWS requests sent by HTTP. For security, most requests to AWS must be signed with an access key, which consists of an access key ID and secret access key. These two keys are commonly referred to as your security credentials. For more information about SigV4, see Signature Version 4 signing process. Using AWS Distro for OpenTelemetry as a collector This section describes how to configure the AWS Distro for OpenTelemetry (ADOT) Collector to scrape |
amazon-managed-prometheus-user-guide-017 | amazon-managed-prometheus-user-guide.pdf | 17 | Amazon Managed Service for Prometheus is the AWS Signature Version 4 signing process (AWS SigV4). Signature Version 4 is the process to add authentication information to AWS requests sent by HTTP. For security, most requests to AWS must be signed with an access key, which consists of an access key ID and secret access key. These two keys are commonly referred to as your security credentials. For more information about SigV4, see Signature Version 4 signing process. Using AWS Distro for OpenTelemetry as a collector This section describes how to configure the AWS Distro for OpenTelemetry (ADOT) Collector to scrape from a Prometheus-instrumented application, and send the metrics to Amazon Managed Service for Prometheus. For more information about the ADOT Collector, see AWS Distro for OpenTelemetry. The following topics describe three different ways to set up ADOT as a collector for your metrics, based on whether your metrics are coming from Amazon EKS, Amazon ECS, or an Amazon EC2 instance. Topics • Set up metrics ingestion using AWS Distro for OpenTelemetry on an Amazon Elastic Kubernetes Service cluster • Set up metrics ingestion from Amazon ECS using AWS Distro for Open Telemetry • Set up metrics ingestion from an Amazon EC2 instance using remote write ADOT collectors 48 Amazon Managed Service for Prometheus User Guide Set up metrics ingestion using AWS Distro for OpenTelemetry on an Amazon Elastic Kubernetes Service cluster You can use the AWS Distor for OpenTelemetry (ADOT) collector to scrape metrics from a Prometheus-instrumented application, and send the metrics to Amazon Managed Service for Prometheus. Note For more information about the ADOT collector, see AWS Distro for OpenTelemetry. For more information about Prometheus-instrumented applications, see What are Prometheus-compatible metrics?. Collecting Prometheus metrics with ADOT involves three OpenTelemetry components: the Prometheus Receiver, the Prometheus Remote Write Exporter, and the Sigv4 Authentication Extension. You can configure the Prometheus Receiver using your existing Prometheus configuration to perform service discovery and metric scraping. The Prometheus Receiver scrapes metrics in the Prometheus exposition format. Any applications or endpoints that you want to scrape should be configured with the Prometheus client library. The Prometheus Receiver supports the full set of Prometheus scraping and re-labeling configurations described in Configuration in the Prometheus documentation. You can paste these configurations directly into your ADOT Collector configurations. The Prometheus Remote Write Exporter uses the remote_write endpoint to send the scraped metrics to your management portal workspace. The HTTP requests to export data will be signed with AWS SigV4, the AWS protocol for secure authentication, with the Sigv4 Authentication Extension. For more information, see Signature Version 4 signing process. The collector automatically discovers Prometheus metrics endpoints on Amazon EKS and uses the configuration found in <kubernetes_sd_config>. The following demo is an example of this configuration on a cluster running Amazon Elastic Kubernetes Service or self-managed Kubernetes. To perform these steps, you must have AWS credentials from any of the potential options in the default AWS credentials chain. For more information, see Configuring the AWS SDK for Go. This demo uses a sample app that is used for ADOT collectors 49 Amazon Managed Service for Prometheus User Guide integration tests of the process. The sample app exposes metrics at the /metrics endpoint, like the Prometheus client library. Prerequisites Before you begin the following ingestion setup steps, you must set up your IAM role for the service account and trust policy. To set up the IAM role for service account and trust policy 1. Create the IAM role for the service account by following the steps in Set up service roles for the ingestion of metrics from Amazon EKS clusters. The ADOT Collector will use this role when it scrapes and exports metrics. 2. Next, edit the trust policy. Open the IAM console at https://console.aws.amazon.com/iam/. 3. In the left navigation pane, choose Roles and find the amp-iamproxy-ingest-role that you created in step 1. 4. Choose the Trust relationships tab and choose Edit trust relationship. 5. In the trust relationship policy JSON, replace aws-amp with adot-col and then choose Update Trust Policy. Your resulting trust policy should look like the following: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::account-id:oidc-provider/ oidc.eks.region.amazonaws.com/id/openid" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "oidc.eks.region.amazonaws.com/id/openid:sub": "system:serviceaccount:adot-col:amp-iamproxy-ingest-service-account" } } } ] } ADOT collectors 50 Amazon Managed Service for Prometheus User Guide 6. Choose the Permissions tab and make sure that the following permissions policy is attached to the role. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "aps:RemoteWrite", "aps:GetSeries", "aps:GetLabels", "aps:GetMetricMetadata" ], "Resource": "*" } ] } Enabling Prometheus metric collection Note When you create a namespace in Amazon EKS, alertmanager and node exporter are disabled by default. To enable Prometheus collection on an Amazon EKS or Kubernetes cluster 1. Fork and clone the sample app from the repository at aws-otel-community. Then |
amazon-managed-prometheus-user-guide-018 | amazon-managed-prometheus-user-guide.pdf | 18 | "oidc.eks.region.amazonaws.com/id/openid:sub": "system:serviceaccount:adot-col:amp-iamproxy-ingest-service-account" } } } ] } ADOT collectors 50 Amazon Managed Service for Prometheus User Guide 6. Choose the Permissions tab and make sure that the following permissions policy is attached to the role. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "aps:RemoteWrite", "aps:GetSeries", "aps:GetLabels", "aps:GetMetricMetadata" ], "Resource": "*" } ] } Enabling Prometheus metric collection Note When you create a namespace in Amazon EKS, alertmanager and node exporter are disabled by default. To enable Prometheus collection on an Amazon EKS or Kubernetes cluster 1. Fork and clone the sample app from the repository at aws-otel-community. Then run the following commands. cd ./sample-apps/prometheus-sample-app docker build . -t prometheus-sample-app:latest 2. Push this image to a registry such as Amazon ECR or DockerHub. 3. Deploy the sample app in the cluster by copying this Kubernetes configuration and applying it. Change the image to the image that you just pushed by replacing {{PUBLIC_SAMPLE_APP_IMAGE}} in the prometheus-sample-app.yaml file. ADOT collectors 51 Amazon Managed Service for Prometheus User Guide curl https://raw.githubusercontent.com/aws-observability/aws-otel-collector/ main/examples/eks/aws-prometheus/prometheus-sample-app.yaml -o prometheus-sample- app.yaml kubectl apply -f prometheus-sample-app.yaml 4. Enter the following command to verify that the sample app has started. In the output of the command, you will see prometheus-sample-app in the NAME column. kubectl get all -n aoc-prometheus-pipeline-demo 5. Start a default instance of the ADOT Collector. To do so, first enter the following command to pull the Kubernetes configuration for ADOT Collector. curl https://raw.githubusercontent.com/aws-observability/aws-otel-collector/main/ examples/eks/aws-prometheus/prometheus-daemonset.yaml -o prometheus-daemonset.yaml Then edit the template file, substituting the remote_write endpoint for your Amazon Managed Service for Prometheus workspace for YOUR_ENDPOINT and your Region for YOUR_REGION. Use the remote_write endpoint that is displayed in the Amazon Managed Service for Prometheus console when you look at your workspace details. You'll also need to change YOUR_ACCOUNT_ID in the service account section of the Kubernetes configuration to your AWS account ID. In this example, the ADOT Collector configuration uses an annotation (scrape=true) to tell which target endpoints to scrape. This allows the ADOT Collector to distinguish the sample app endpoint from kube-system endpoints in your cluster. You can remove this from the re- label configurations if you want to scrape a different sample app. 6. Enter the following command to deploy the ADOT collector. kubectl apply -f prometheus-daemonset.yaml 7. Enter the following command to verify that the ADOT collector has started. Look for adot- col in the NAMESPACE column. kubectl get pods -n adot-col 8. Verify that the pipeline works by using the logging exporter. Our example template is already integrated with the logging exporter. Enter the following commands. ADOT collectors 52 Amazon Managed Service for Prometheus User Guide kubectl get pods -A kubectl logs -n adot-col name_of_your_adot_collector_pod Some of the scraped metrics from the sample app will look like the following example. Resource labels: -> service.name: STRING(kubernetes-service-endpoints) -> host.name: STRING(192.168.16.238) -> port: STRING(8080) -> scheme: STRING(http) InstrumentationLibraryMetrics #0 Metric #0 Descriptor: -> Name: test_gauge0 -> Description: This is my gauge -> Unit: -> DataType: DoubleGauge DoubleDataPoints #0 StartTime: 0 Timestamp: 1606511460471000000 Value: 0.000000 9. To test whether Amazon Managed Service for Prometheus received the metrics, use awscurl. This tool enables you to send HTTP requests through the command line with AWS Sigv4 authentication, so you must have AWS credentials set up locally with the correct permissions to query from Amazon Managed Service for Prometheus For instructions on installing awscurl, see awscurl. In the following command, replace AMP_REGION, and AMP_ENDPOINT with the information for your Amazon Managed Service for Prometheus workspace. awscurl --service="aps" --region="AMP_REGION" "https://AMP_ENDPOINT/api/v1/query? query=adot_test_gauge0" {"status":"success","data":{"resultType":"vector","result":[{"metric": {"__name__":"adot_test_gauge0"},"value":[1606512592.493,"16.87214000011479"]}]}} If you receive a metric as the response, that means your pipeline setup has been successful and the metric has successfully propagated from the sample app into Amazon Managed Service for Prometheus. ADOT collectors 53 Amazon Managed Service for Prometheus User Guide Cleaning up To clean up this demo, enter the following commands. kubectl delete namespace aoc-prometheus-pipeline-demo kubectl delete namespace adot-col Advanced configuration The Prometheus Receiver supports the full set of Prometheus scraping and re-labeling configurations described in Configuration in the Prometheus documentation. You can paste these configurations directly into your ADOT Collector configurations. The configuration for the Prometheus Receiver includes your service discovery, scraping configurations, and re-labeling configurations. The receiver configuration looks like the following. receivers: prometheus: config: [[Your Prometheus configuration]] The following is an example configuration. receivers: prometheus: config: global: scrape_interval: 1m scrape_timeout: 10s scrape_configs: - job_name: kubernetes-service-endpoints sample_limit: 10000 kubernetes_sd_configs: - role: endpoints tls_config: ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt insecure_skip_verify: true bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token If you have an existing Prometheus configuration, you must replace the $ characters with $$ to avoid having the values replaced with environment variables. *This is especially important for ADOT collectors 54 Amazon Managed Service for Prometheus User Guide the replacement value of the relabel_configurations. For example, if you start with the following relabel_configuration: relabel_configs: - source_labels: [__meta_kubernetes_ingress_scheme,__address__,__meta_kubernetes_ingress_path] regex: (.+);(.+);(.+) replacement: ${1}://${2}${3} target_label: __param_target It |
amazon-managed-prometheus-user-guide-019 | amazon-managed-prometheus-user-guide.pdf | 19 | config: [[Your Prometheus configuration]] The following is an example configuration. receivers: prometheus: config: global: scrape_interval: 1m scrape_timeout: 10s scrape_configs: - job_name: kubernetes-service-endpoints sample_limit: 10000 kubernetes_sd_configs: - role: endpoints tls_config: ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt insecure_skip_verify: true bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token If you have an existing Prometheus configuration, you must replace the $ characters with $$ to avoid having the values replaced with environment variables. *This is especially important for ADOT collectors 54 Amazon Managed Service for Prometheus User Guide the replacement value of the relabel_configurations. For example, if you start with the following relabel_configuration: relabel_configs: - source_labels: [__meta_kubernetes_ingress_scheme,__address__,__meta_kubernetes_ingress_path] regex: (.+);(.+);(.+) replacement: ${1}://${2}${3} target_label: __param_target It would become the following: relabel_configs: - source_labels: [__meta_kubernetes_ingress_scheme,__address__,__meta_kubernetes_ingress_path] regex: (.+);(.+);(.+) replacement: $${1}://${2}${3} target_label: __param_target Prometheus remote write exporter and Sigv4 authentication extension The configuration for the Prometheus Remote Write Exporter and Sigv4 Authentication Extension are simpler than the Prometheus receiver. At this stage in the pipeline, metrics have already been ingested, and we’re ready to export this data to Amazon Managed Service for Prometheus. The minimum requirement for a successful configuration to communicate with Amazon Managed Service for Prometheus is shown in the following example. extensions: sigv4auth: service: "aps" region: "user-region" exporters: prometheusremotewrite: endpoint: "https://aws-managed-prometheus-endpoint/api/v1/remote_write" auth: authenticator: "sigv4auth" This configuration sends an HTTPS request that is signed by AWS SigV4 using AWS credentials from the default AWS credentials chain. For more information, see Configuring the AWS SDK for Go. You must specify the service to be aps. ADOT collectors 55 Amazon Managed Service for Prometheus User Guide Regardless of the method of deployment, the ADOT collector must have access to one of the listed options in the default AWS credentials chain. The Sigv4 Authentication Extension depends on the AWS SDK for Go and uses it to fetch credentials and authenticate. You must ensure that these credentials have remote write permissions for Amazon Managed Service for Prometheus. Set up metrics ingestion from Amazon ECS using AWS Distro for Open Telemetry This section explains how to collect metrics from Amazon Elastic Container Service (Amazon ECS) and ingest them into Amazon Managed Service for Prometheus using AWS Distro for Open Telemetry (ADOT). It also describes how to visualize your metrics in Amazon Managed Grafana. Prerequisites Important Before you begin, you must have an Amazon ECS environment on an AWS Fargate cluster with default settings, an Amazon Managed Service for Prometheus workspace, and an Amazon Managed Grafana workspace. We assume that you are familiar with container workloads, Amazon Managed Service for Prometheus, and Amazon Managed Grafana. For more information, see the following links: • For information about how to create an Amazon ECS environment on a Fargate cluster with default settings, see Creating a cluster in the Amazon ECS Developer Guide. • For information about how to create an Amazon Managed Service for Prometheus workspace, see Create a workspace in the Amazon Managed Service for Prometheus User Guide. • For information about how to create an Amazon Managed Grafana workspace, see Creating a workspace in the Amazon Managed Grafana User Guide. Step 1: Define a custom ADOT collector container image Use the following config file as a template to define your own ADOT collector container image. Replace my-remote-URL and my-region with your endpoint and region values. Save the config in a file called adot-config.yaml. ADOT collectors 56 Amazon Managed Service for Prometheus User Guide Note This configuration uses the sigv4auth extension to authenticate calls to Amazon Managed Service for Prometheus. For more information about configuring sigv4auth, see Authenticator - Sigv4 on GitHub. receivers: prometheus: config: global: scrape_interval: 15s scrape_timeout: 10s scrape_configs: - job_name: "prometheus" static_configs: - targets: [ 0.0.0.0:9090 ] awsecscontainermetrics: collection_interval: 10s processors: filter: metrics: include: match_type: strict metric_names: - ecs.task.memory.utilized - ecs.task.memory.reserved - ecs.task.cpu.utilized - ecs.task.cpu.reserved - ecs.task.network.rate.rx - ecs.task.network.rate.tx - ecs.task.storage.read_bytes - ecs.task.storage.write_bytes exporters: prometheusremotewrite: endpoint: my-remote-URL auth: authenticator: sigv4auth logging: loglevel: info extensions: health_check: ADOT collectors 57 Amazon Managed Service for Prometheus User Guide pprof: endpoint: :1888 zpages: endpoint: :55679 sigv4auth: region: my-region service: aps service: extensions: [pprof, zpages, health_check, sigv4auth] pipelines: metrics: receivers: [prometheus] exporters: [logging, prometheusremotewrite] metrics/ecs: receivers: [awsecscontainermetrics] processors: [filter] exporters: [logging, prometheusremotewrite] Step 2: Push your ADOT collector container image to an Amazon ECR repository Use a Dockerfile to create and push your container image to an Amazon Elastic Container Registry (ECR) repository. 1. Build the Dockerfile to copy and add your container image to the OTEL Docker image. FROM public.ecr.aws/aws-observability/aws-otel-collector:latest COPY adot-config.yaml /etc/ecs/otel-config.yaml CMD ["--config=/etc/ecs/otel-config.yaml"] 2. Create an Amazon ECR repository. # create repo: COLLECTOR_REPOSITORY=$(aws ecr create-repository --repository aws-otel-collector \ --query repository.repositoryUri --output text) 3. Create your container image. # build ADOT collector image: docker build -t $COLLECTOR_REPOSITORY:ecs . ADOT collectors 58 Amazon Managed Service for Prometheus User Guide Note This assumes you are building your container in the same environment that it will run in. If not, you may need to use the --platform |
amazon-managed-prometheus-user-guide-020 | amazon-managed-prometheus-user-guide.pdf | 20 | an Amazon Elastic Container Registry (ECR) repository. 1. Build the Dockerfile to copy and add your container image to the OTEL Docker image. FROM public.ecr.aws/aws-observability/aws-otel-collector:latest COPY adot-config.yaml /etc/ecs/otel-config.yaml CMD ["--config=/etc/ecs/otel-config.yaml"] 2. Create an Amazon ECR repository. # create repo: COLLECTOR_REPOSITORY=$(aws ecr create-repository --repository aws-otel-collector \ --query repository.repositoryUri --output text) 3. Create your container image. # build ADOT collector image: docker build -t $COLLECTOR_REPOSITORY:ecs . ADOT collectors 58 Amazon Managed Service for Prometheus User Guide Note This assumes you are building your container in the same environment that it will run in. If not, you may need to use the --platform parameter when building the image. 4. Sign in to the Amazon ECR repository. Replace my-region with your region value. # sign in to repo: aws ecr get-login-password --region my-region | \ docker login --username AWS --password-stdin $COLLECTOR_REPOSITORY 5. Push your container image. # push ADOT collector image: docker push $COLLECTOR_REPOSITORY:ecs Step 3: Create an Amazon ECS task definition to scrape Amazon Managed Service for Prometheus Create an Amazon ECS task definition to scrape Amazon Managed Service for Prometheus. Your task definition should include a container named adot-collector and a container named prometheus. prometheus generates metrics, and adot-collector scrapes prometheus. Note Amazon Managed Service for Prometheus runs as a service, collecting metrics from containers. The containers in this case run Prometheus locally, in Agent mode, which send the local metrics to Amazon Managed Service for Prometheus. Example: Task definition The following is an example of how your task definition might look. You can use this example as a template to create your own task definition. Replace the image value of adot-collector with your repository URL and image tag ($COLLECTOR_REPOSITORY:ecs). Replace the region values of adot-collector and prometheus with your region values. { ADOT collectors 59 Amazon Managed Service for Prometheus User Guide "family": "adot-prom", "networkMode": "awsvpc", "containerDefinitions": [ { "name": "adot-collector", "image": "account_id.dkr.ecr.region.amazonaws.com/image-tag", "essential": true, "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/ecs-adot-collector", "awslogs-region": "my-region", "awslogs-stream-prefix": "ecs", "awslogs-create-group": "True" } } }, { "name": "prometheus", "image": "prom/prometheus:main", "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/ecs-prom", "awslogs-region": "my-region", "awslogs-stream-prefix": "ecs", "awslogs-create-group": "True" } } } ], "requiresCompatibilities": [ "FARGATE" ], "cpu": "1024" } Step 4: Give your task permissions to access Amazon Managed Service for Prometheus To send the scraped metrics to Amazon Managed Service for Prometheus, your Amazon ECS task must have the correct permissions to call the AWS API operations for you. You must create an IAM role for your tasks and attach the AmazonPrometheusRemoteWriteAccess policy to it. For more ADOT collectors 60 Amazon Managed Service for Prometheus User Guide information about creating this role and attaching the policy, see Creating an IAM role and policy for your tasks. After you attach AmazonPrometheusRemoteWriteAccess to your IAM role, and use that role for your tasks, Amazon ECS can send your scraped metrics to Amazon Managed Service for Prometheus. Step 5: Visualize your metrics in Amazon Managed Grafana Important Before you begin, you must run a Fargate task on your Amazon ECS task definition. Otherwise, Amazon Managed Service for Prometheus can't consume your metrics. 1. From the navigation pane in your Amazon Managed Grafana workspace, choose Data sources under the AWS icon. 2. On the Data sources tab, for Service, select Amazon Managed Service for Prometheus and choose your Default Region. 3. Choose Add data source. 4. Use the ecs and prometheus prefixes to query and view your metrics. Set up metrics ingestion from an Amazon EC2 instance using remote write This section explains how to run a Prometheus server with remote write in an Amazon Elastic Compute Cloud (Amazon EC2) instance. It explains how to collect metrics from a demo application written in Go and send them to an Amazon Managed Service for Prometheus workspace. Prerequisites Important Before you start, you must have installed Prometheus v2.26 or later. We assume that you're familiar with Prometheus, Amazon EC2, and Amazon Managed Service for Prometheus. For information about how to install Prometheus, see Getting started on the Prometheus website. ADOT collectors 61 Amazon Managed Service for Prometheus User Guide If you're unfamiliar with Amazon EC2 or Amazon Managed Service for Prometheus, we recommend that you start by reading the following sections: • What is Amazon Elastic Compute Cloud? • What is Amazon Managed Service for Prometheus? Create an IAM role for Amazon EC2 To stream metrics, you must first create an IAM role with the AWS managed policy AmazonPrometheusRemoteWriteAccess. Then, you can launch an instance with the role and stream metrics into your Amazon Managed Service for Prometheus workspace. 1. Open the IAM console at https://console.aws.amazon.com/iam/. 2. 3. 4. 5. 6. From the navigation pane, choose Roles, and then choose Create role. For the type of trusted entity, choose AWS service. For the use case, choose EC2. Choose Next: Permissions. In the search |
amazon-managed-prometheus-user-guide-021 | amazon-managed-prometheus-user-guide.pdf | 21 | is Amazon Elastic Compute Cloud? • What is Amazon Managed Service for Prometheus? Create an IAM role for Amazon EC2 To stream metrics, you must first create an IAM role with the AWS managed policy AmazonPrometheusRemoteWriteAccess. Then, you can launch an instance with the role and stream metrics into your Amazon Managed Service for Prometheus workspace. 1. Open the IAM console at https://console.aws.amazon.com/iam/. 2. 3. 4. 5. 6. From the navigation pane, choose Roles, and then choose Create role. For the type of trusted entity, choose AWS service. For the use case, choose EC2. Choose Next: Permissions. In the search bar, enter AmazonPrometheusRemoteWriteAccess. For Policy name, select AmazonPrometheusRemoteWriteAccess, and then choose Attach policy. Choose Next:Tags. (Optional) Create IAM tags for your IAM role. Choose Next: Review. Enter a name for your role. Choose Create policy. Launch an Amazon EC2 instance To launch an Amazon EC2 instance, follow the instructions at Launch an instance in the Amazon Elastic Compute Cloud User Guide for Linux Instances. Run the demo application After creating your IAM role, and launching an EC2 instance with the role, you can run a demo application to see it work. To run a demo application and test metrics 1. Use the following template to create a Go file named main.go. package main import ( ADOT collectors 62 Amazon Managed Service for Prometheus User Guide "github.com/prometheus/client_golang/prometheus/promhttp" "net/http" ) func main() { http.Handle("/metrics", promhttp.Handler()) http.ListenAndServe(":8000", nil) } 2. Run the following commands to install the correct dependencies. sudo yum update -y sudo yum install -y golang go get github.com/prometheus/client_golang/prometheus/promhttp 3. Run the demo application. go run main.go The demo application should run on port 8000 and show all of the exposed Prometheus metrics. The following is an example of these metrics. curl -s http://localhost:8000/metrics ... process_max_fds 4096# HELP process_open_fds Number of open file descriptors.# TYPE process_open_fds gauge process_open_fds 10# HELP process_resident_memory_bytes Resident memory size in bytes.# TYPE process_resident_memory_bytes gauge process_resident_memory_bytes 1.0657792e+07# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.# TYPE process_start_time_seconds gauge process_start_time_seconds 1.61131955899e+09# HELP process_virtual_memory_bytes Virtual memory size in bytes.# TYPE process_virtual_memory_bytes gauge process_virtual_memory_bytes 7.77281536e+08# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.# TYPE process_virtual_memory_max_bytes gauge process_virtual_memory_max_bytes -1# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.# TYPE promhttp_metric_handler_requests_in_flight gauge ADOT collectors 63 Amazon Managed Service for Prometheus User Guide promhttp_metric_handler_requests_in_flight 1# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.# TYPE promhttp_metric_handler_requests_total counter promhttp_metric_handler_requests_total{code="200"} 1 promhttp_metric_handler_requests_total{code="500"} 0 promhttp_metric_handler_requests_total{code="503"} 0 Create an Amazon Managed Service for Prometheus workspace To create an Amazon Managed Service for Prometheus workspace, follow the instructions at Create a workspace. Run a Prometheus server 1. Use the following example YAML file as a template to create a new file named prometheus.yaml. For url, replace my-region with your Region value and my- workspace-id with the workspace ID that Amazon Managed Service for Prometheus generated for you. For region, replace my-region with your Region value. Example: YAML file global: scrape_interval: 15s external_labels: monitor: 'prometheus' scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:8000'] remote_write: - url: https://aps-workspaces.my-region.amazonaws.com/workspaces/my-workspace-id/ api/v1/remote_write queue_config: max_samples_per_send: 1000 max_shards: 200 capacity: 2500 sigv4: region: my-region ADOT collectors 64 Amazon Managed Service for Prometheus User Guide 2. Run the Prometheus server to send the demo application’s metrics to your Amazon Managed Service for Prometheus workspace. prometheus --config.file=prometheus.yaml The Prometheus server should now send the demo application’s metrics to your Amazon Managed Service for Prometheus workspace. Using a Prometheus instance as a collector You can use a Prometheus instance, running in agent mode (known as a Prometheus agent), to scrape metrics and send them to your Amazon Managed Service for Prometheus workspace. The following topics describe different ways to set up a Prometheus instance running in agent mode as a collector for your metrics. Warning When you create a Prometheus agent, you are responsible for its configuration and maintenance. Avoid exposing Prometheus scrape endpoints to the public internet by enabling security features. If you set up multiple Prometheus instances that monitor the same set of metrics and sent them to a single Amazon Managed Service for Prometheus workspace for high availability, you need to set up deduplication. If you don't follow the steps to set up deduplication, you will be charged for all data samples sent to Amazon Managed Service for Prometheus, including duplicate samples. For instructions about setting up deduplication, see Deduplicating high availability metrics sent to Amazon Managed Service for Prometheus. Topics • Set up ingestion from a new Prometheus server using Helm • Set up ingestion from an existing Prometheus server in Kubernetes on EC2 • Set up ingestion from an existing Prometheus server in Kubernetes on Fargate Prometheus collectors 65 Amazon Managed Service for Prometheus User Guide Set up ingestion from a new Prometheus server using Helm The instructions in this section get you up and running with |
amazon-managed-prometheus-user-guide-022 | amazon-managed-prometheus-user-guide.pdf | 22 | all data samples sent to Amazon Managed Service for Prometheus, including duplicate samples. For instructions about setting up deduplication, see Deduplicating high availability metrics sent to Amazon Managed Service for Prometheus. Topics • Set up ingestion from a new Prometheus server using Helm • Set up ingestion from an existing Prometheus server in Kubernetes on EC2 • Set up ingestion from an existing Prometheus server in Kubernetes on Fargate Prometheus collectors 65 Amazon Managed Service for Prometheus User Guide Set up ingestion from a new Prometheus server using Helm The instructions in this section get you up and running with Amazon Managed Service for Prometheus quickly. You set up a new Prometheus server in an Amazon EKS cluster, and the new server uses a default configuration to send metrics to Amazon Managed Service for Prometheus. This method has the following prerequisites: • You must have an Amazon EKS cluster from which the new Prometheus server will collect metrics. • Your Amazon EKS cluster must have an Amazon EBS CSI driver installed (required by Helm). • You must use Helm CLI 3.0 or later. • You must use a Linux or macOS computer to perform the steps in the following sections. Step 1: Add new Helm chart repositories To add new Helm chart repositories, enter the following commands. For more information about these commands, see Helm Repo. helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo add kube-state-metrics https://kubernetes.github.io/kube-state-metrics helm repo update Step 2: Create a Prometheus namespace Enter the following command to create a Prometheus namespace for the Prometheus server and other monitoring components. Replace prometheus-namespace with the name that you want for this namespace. kubectl create namespace prometheus-namespace Step 3: Set up IAM roles for service accounts For the method of onboarding that we are documenting, you need to use IAM roles for service accounts in the Amazon EKS cluster where the Prometheus server is running. With IAM roles for service accounts, you can associate an IAM role with a Kubernetes service account. This service account can then provide AWS permissions to the containers in any pod that uses that service account. For more information, see IAM roles for service accounts. Prometheus collectors 66 Amazon Managed Service for Prometheus User Guide If you have not already set up these roles, follow the instructions at Set up service roles for the ingestion of metrics from Amazon EKS clusters to set up the roles. The instructions in that section require the use of eksctl. For more information, see Getting started with Amazon Elastic Kubernetes Service – eksctl. Note When you are not on EKS or AWS and using just access key and secret key to access Amazon Managed Service for Prometheus, you cannot use the EKS-IAM-ROLE based SigV4. Step 4: Set up the new server and start ingesting metrics To install the new Prometheus server that sends metrics to your Amazon Managed Service for Prometheus workspace, follow these steps. To install a new Prometheus server to send metrics to your Amazon Managed Service for Prometheus workspace 1. Use a text editor to create a file named my_prometheus_values_yaml with the following content. • Replace IAM_PROXY_PROMETHEUS_ROLE_ARN with the ARN of the amp-iamproxy-ingest- role that you created in Set up service roles for the ingestion of metrics from Amazon EKS clusters. • Replace WORKSPACE_ID with the ID of your Amazon Managed Service for Prometheus workspace. • Replace REGION with the Region of your Amazon Managed Service for Prometheus workspace. ## The following is a set of default values for prometheus server helm chart which enable remoteWrite to AMP ## For the rest of prometheus helm chart values see: https://github.com/prometheus- community/helm-charts/blob/main/charts/prometheus/values.yaml ## serviceAccounts: server: name: amp-iamproxy-ingest-service-account annotations: Prometheus collectors 67 Amazon Managed Service for Prometheus User Guide eks.amazonaws.com/role-arn: ${IAM_PROXY_PROMETHEUS_ROLE_ARN} server: remoteWrite: - url: https://aps-workspaces.${REGION}.amazonaws.com/workspaces/ ${WORKSPACE_ID}/api/v1/remote_write sigv4: region: ${REGION} queue_config: max_samples_per_send: 1000 max_shards: 200 capacity: 2500 2. Enter the following command to create the Prometheus server. • Replace prometheus-chart-name with your Prometheus release name. • Replace prometheus-namespace with the name of your Prometheus namespace. helm install prometheus-chart-name prometheus-community/prometheus -n prometheus- namespace \ -f my_prometheus_values_yaml Note You can customize the helm install command in many ways. For more information, see Helm install in the Helm documentation. Set up ingestion from an existing Prometheus server in Kubernetes on EC2 Amazon Managed Service for Prometheus supports ingesting metrics from Prometheus servers in clusters running Amazon EKS and in self-managed Kubernetes clusters running on Amazon EC2. The detailed instructions in this section are for a Prometheus server in an Amazon EKS cluster. The steps for a self-managed Kubernetes cluster on Amazon EC2 are the same, except that you will need to set up the OIDC provider and IAM roles for service accounts yourself in the Kubernetes cluster. The instructions in this section use Helm as the Kubernetes package manager. Topics Prometheus collectors |
amazon-managed-prometheus-user-guide-023 | amazon-managed-prometheus-user-guide.pdf | 23 | from an existing Prometheus server in Kubernetes on EC2 Amazon Managed Service for Prometheus supports ingesting metrics from Prometheus servers in clusters running Amazon EKS and in self-managed Kubernetes clusters running on Amazon EC2. The detailed instructions in this section are for a Prometheus server in an Amazon EKS cluster. The steps for a self-managed Kubernetes cluster on Amazon EC2 are the same, except that you will need to set up the OIDC provider and IAM roles for service accounts yourself in the Kubernetes cluster. The instructions in this section use Helm as the Kubernetes package manager. Topics Prometheus collectors 68 Amazon Managed Service for Prometheus User Guide • Step 1: Set up IAM roles for service accounts • Step 2: Upgrade your existing Prometheus server using Helm Step 1: Set up IAM roles for service accounts For the method of onboarding that we are documenting, you need to use IAM roles for service accounts in the Amazon EKS cluster where the Prometheus server is running. These roles are also called service roles. With service roles, you can associate an IAM role with a Kubernetes service account. This service account can then provide AWS permissions to the containers in any pod that uses that service account. For more information, see IAM roles for service accounts. If you have not already set up these roles, follow the instructions at Set up service roles for the ingestion of metrics from Amazon EKS clusters to set up the roles. Step 2: Upgrade your existing Prometheus server using Helm The instructions in this section include setting up remote write and sigv4 to authenticate and authorize the Prometheus server to remote write to your Amazon Managed Service for Prometheus workspace. Using Prometheus version 2.26.0 or later Follow these steps if you are using a Helm chart with Prometheus Server image of version 2.26.0 or later. To set up remote write from a Prometheus server using Helm chart 1. Create a new remote write section in your Helm configuration file: • Replace ${IAM_PROXY_PROMETHEUS_ROLE_ARN} with the ARN of the amp-iamproxy- ingest-role that you created in Step 1: Set up IAM roles for service accounts. The role ARN should have the format of arn:aws:iam::your account ID:role/amp-iamproxy- ingest-role. • Replace ${WORKSPACE_ID} with your Amazon Managed Service for Prometheus workspace ID. • Replace ${REGION} with the Region of the Amazon Managed Service for Prometheus workspace (such as us-west-2). Prometheus collectors 69 Amazon Managed Service for Prometheus User Guide ## The following is a set of default values for prometheus server helm chart which enable remoteWrite to AMP ## For the rest of prometheus helm chart values see: https://github.com/ prometheus-community/helm-charts/blob/main/charts/prometheus/values.yaml ## serviceAccounts: server: name: amp-iamproxy-ingest-service-account annotations: eks.amazonaws.com/role-arn: ${IAM_PROXY_PROMETHEUS_ROLE_ARN} server: remoteWrite: - url: https://aps-workspaces.${REGION}.amazonaws.com/workspaces/ ${WORKSPACE_ID}/api/v1/remote_write sigv4: region: ${REGION} queue_config: max_samples_per_send: 1000 max_shards: 200 capacity: 2500 2. Update your existing Prometheus Server configuration using Helm: • Replace prometheus-chart-name with your Prometheus release name. • Replace prometheus-namespace with the Kubernetes namespace where your Prometheus Server is installed. • Replace my_prometheus_values_yaml with the path to your Helm configuration file. • Replace current_helm_chart_version with the current version of your Prometheus Server Helm chart. You can find the current chart version by using the helm list command. helm upgrade prometheus-chart-name prometheus-community/prometheus \ -n prometheus-namespace \ -f my_prometheus_values_yaml \ --version current_helm_chart_version Prometheus collectors 70 Amazon Managed Service for Prometheus User Guide Using earlier versions of Prometheus Follow these steps if you are using a version of Prometheus earlier than 2.26.0. These steps use a sidecar approach, because earlier versions of Prometheus don't natively support AWS Signature Version 4 signing process (AWS SigV4). These instructions assume that you are using Helm to deploy Prometheus. To set up remote write from a Prometheus server 1. On your Prometheus server, create a new remote write configuration. First, create a new update file. We will call the file amp_ingest_override_values.yaml. Add the following values to the YAML file. serviceAccounts: server: name: "amp-iamproxy-ingest-service-account" annotations: eks.amazonaws.com/role-arn: "${SERVICE_ACCOUNT_IAM_INGEST_ROLE_ARN}" server: sidecarContainers: - name: aws-sigv4-proxy-sidecar image: public.ecr.aws/aws-observability/aws-sigv4-proxy:1.0 args: - --name - aps - --region - ${REGION} - --host - aps-workspaces.${REGION}.amazonaws.com - --port - :8005 ports: - name: aws-sigv4-proxy containerPort: 8005 statefulSet: enabled: "true" remoteWrite: - url: http://localhost:8005/workspaces/${WORKSPACE_ID}/api/v1/ remote_write Prometheus collectors 71 Amazon Managed Service for Prometheus User Guide Replace ${REGION} with the Region of the Amazon Managed Service for Prometheus workspace. Replace ${SERVICE_ACCOUNT_IAM_INGEST_ROLE_ARN} with the ARN of the amp- iamproxy-ingest-role that you created in Step 1: Set up IAM roles for service accounts. The role ARN should have the format of arn:aws:iam::your account ID:role/amp- iamproxy-ingest-role. Replace ${WORKSPACE_ID} with your workspace ID. 2. Upgrade your Prometheus Helm chart. First, find your Helm chart name by entering the following command. In the output from this command, look for a chart with a name that includes prometheus. helm ls --all-namespaces Then enter the following command. helm upgrade --install prometheus-helm-chart-name prometheus-community/prometheus - |
amazon-managed-prometheus-user-guide-024 | amazon-managed-prometheus-user-guide.pdf | 24 | Replace ${REGION} with the Region of the Amazon Managed Service for Prometheus workspace. Replace ${SERVICE_ACCOUNT_IAM_INGEST_ROLE_ARN} with the ARN of the amp- iamproxy-ingest-role that you created in Step 1: Set up IAM roles for service accounts. The role ARN should have the format of arn:aws:iam::your account ID:role/amp- iamproxy-ingest-role. Replace ${WORKSPACE_ID} with your workspace ID. 2. Upgrade your Prometheus Helm chart. First, find your Helm chart name by entering the following command. In the output from this command, look for a chart with a name that includes prometheus. helm ls --all-namespaces Then enter the following command. helm upgrade --install prometheus-helm-chart-name prometheus-community/prometheus - n prometheus-namespace -f ./amp_ingest_override_values.yaml Replace prometheus-helm-chart-name with the name of the Prometheus helm chart returned in the previous command. Replace prometheus-namespace with the name of your namespace. Downloading Helm charts If you don't already have Helm charts downloaded locally, you can use the following command to download them. helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm pull prometheus-community/prometheus --untar Set up ingestion from an existing Prometheus server in Kubernetes on Fargate Amazon Managed Service for Prometheus supports ingesting metrics from Prometheus servers in self-managed Kubernetes clusters running on Fargate. To ingest metrics from Prometheus servers Prometheus collectors 72 Amazon Managed Service for Prometheus User Guide in Amazon EKS clusters running on Fargate, override the default configs in a config file named amp_ingest_override_values.yaml as follows: prometheus-node-exporter: enabled: false alertmanager: enabled: false serviceAccounts: server: name: amp-iamproxy-ingest-service-account annotations: eks.amazonaws.com/role-arn: ${IAM_PROXY_PROMETHEUS_ROLE_ARN} server: persistentVolume: enabled: false remoteWrite: - url: https://aps-workspaces.${REGION}.amazonaws.com/workspaces/ ${WORKSPACE_ID}/api/v1/remote_write sigv4: region: ${REGION} queue_config: max_samples_per_send: 1000 max_shards: 200 capacity: 2500 Install Prometheus using the overrides with the following command: helm install prometheus-for-amp prometheus-community/prometheus \ -n prometheus \ -f amp_ingest_override_values.yaml Note that in the Helm chart configuration we disabled the node exporter and the alert manager as well as running the Prometheus server deployment. You can verify the install with the following example test query. $ awscurl --region region --service aps "https://aps- workspaces.region_id.amazonaws.com/workspaces/workspace_id/api/v1/query? query=prometheus_api_remote_read_queries" Prometheus collectors 73 Amazon Managed Service for Prometheus User Guide {"status":"success","data":{"resultType":"vector","result":[{"metric": {"__name__":"prometheus_api_remote_read_queries","instance":"localhost:9090","job":"prometheus"},"value": [1648461236.419,"0"]}]}}21 Set up Amazon Managed Service for Prometheus for high availability data When you send data to Amazon Managed Service for Prometheus, it is automatically replicated across AWS Availability Zones in the Region, and is served to you from a cluster of hosts that provide scalability, availability, and security. You might want to add additional high availability fail- safes, depending on your particular setup. There are two common ways that you might additional high availability safeties to your setup: • If you have multiple containers or instances that have the same data, you can send that data to Amazon Managed Service for Prometheus and have the data automatically de-duplicated. This helps to ensure that your data will be sent to your Amazon Managed Service for Prometheus workspace. For more information about de-duplicating high-availability data, see Deduplicating high availability metrics sent to Amazon Managed Service for Prometheus. • If you want to ensure that you have access to your data, even when the AWS Region is not available, you can send your metrics to a second workspace, in another Region. For more information about sending metrics data to multiple workspaces, see Use cross Region workspaces to add high availability in Amazon Managed Service for Prometheus. Topics • Deduplicating high availability metrics sent to Amazon Managed Service for Prometheus • Send high availability data to Amazon Managed Service for Prometheus with Prometheus • Set up high availability data to Amazon Managed Service for Prometheus using the Prometheus Operator Helm chart • Send high-availability data to Amazon Managed Service for Prometheus with AWS Distro for OpenTelemetry • Send high availability data to Amazon Managed Service for Prometheus with the Prometheus community Helm chart High-availability data 74 Amazon Managed Service for Prometheus User Guide • Answers to common questions about high availability configuration in Amazon Managed Service for Prometheus • Use cross Region workspaces to add high availability in Amazon Managed Service for Prometheus Deduplicating high availability metrics sent to Amazon Managed Service for Prometheus You can send data from multiple Prometheus agents (Prometheus instances running in Agent mode) to your Amazon Managed Service for Prometheus workspace. If some of these instances are recording and sending the same metrics, your data will have a higher availability (even if one of the agents stops sending data, the Amazon Managed Service for Prometheus workspace will still receive the data from another instance). However, you want your Amazon Managed Service for Prometheus workspace to automatically de-duplicate the metrics so that you don't see the metrics multiple times, and aren't charged for the data ingestion and storage multiple times. For Amazon Managed Service for Prometheus to automatically de-duplicate data from multiple Prometheus agents, you give the set of agents that are sending the duplicate data a single cluster name, and each of the instances a replica name. The cluster |
amazon-managed-prometheus-user-guide-025 | amazon-managed-prometheus-user-guide.pdf | 25 | availability (even if one of the agents stops sending data, the Amazon Managed Service for Prometheus workspace will still receive the data from another instance). However, you want your Amazon Managed Service for Prometheus workspace to automatically de-duplicate the metrics so that you don't see the metrics multiple times, and aren't charged for the data ingestion and storage multiple times. For Amazon Managed Service for Prometheus to automatically de-duplicate data from multiple Prometheus agents, you give the set of agents that are sending the duplicate data a single cluster name, and each of the instances a replica name. The cluster name identifies the instances as having shared data, and the replica name allows Amazon Managed Service for Prometheus to identify the source of each metric. The final stored metrics include the cluster label, but not the replica, so the metrics appear to be coming from a single source. Note Certain versions of Kubernetes (1.28 and 1.29) may emit their own metric with a cluster label. This can cause issues with Amazon Managed Service for Prometheus deduplication. See the High availability FAQ for more information. The following topics show how to send data and include the cluster and __replica__ labels, so that Amazon Managed Service for Prometheus de-duplicates the data automatically. Important If you do not set up deduplication, you will be charged for all data samples that are sent to Amazon Managed Service for Prometheus. These data samples include duplicate samples. High-availability data 75 Amazon Managed Service for Prometheus User Guide Send high availability data to Amazon Managed Service for Prometheus with Prometheus To set up a high availability configuration with Prometheus, you must apply external labels on all instances of a high availability group, so Amazon Managed Service for Prometheus can identify them. Use the cluster label to identify a Prometheus instance agent as part of a high availability group. Use the __replica__ label to identify each replica in the group separately. You need to apply both __replica__ and cluster labels for de-duplication to work. Note The __replica__ label is formatted with two underscore symbols before and after the word replica. Example: code snippets In the following code snippets, the cluster label identifies the Prometheus instance agent prom- team1, and the _replica_ label identifies the replicas replica1 and replica2. cluster: prom-team1 __replica__: replica1 cluster: prom-team1 __replica__: replica2 As Amazon Managed Service for Prometheus stores data samples from high availability replicas with these labels, it strips the replica label when the samples are accepted. This means that you will only have a 1:1 series mapping for your current series instead of a series per replica. The cluster label is kept. Note Certain versions of Kubernetes (1.28 and 1.29) may emit their own metric with a cluster label. This can cause issues with Amazon Managed Service for Prometheus deduplication. See the High availability FAQ for more information. High-availability data 76 Amazon Managed Service for Prometheus User Guide Set up high availability data to Amazon Managed Service for Prometheus using the Prometheus Operator Helm chart To set up a high availability configuration with the Prometheus Operator in Helm, you must apply external labels on all instances of a high availability group, so Amazon Managed Service for Prometheus can identify them. You also must set the attributes replicaExternalLabelName and externalLabels on the Prometheus Operator Helm chart. Example: YAML header In the following YAML header, cluster is added to externalLabel to identify a Prometheus instance agent as part of a high-availability group, and replicaExternalLabels identifies each replica in the group. replicaExternalLabelName: __replica__ externalLabels: cluster: prom-dev Note Certain versions of Kubernetes (1.28 and 1.29) may emit their own metric with a cluster label. This can cause issues with Amazon Managed Service for Prometheus deduplication. See the High availability FAQ for more information. Send high-availability data to Amazon Managed Service for Prometheus with AWS Distro for OpenTelemetry AWS Distro for OpenTelemetry (ADOT) is a secure and production-ready distribution of the OpenTelemetry project. ADOT provides you with source APIs, libraries, and agents, so you can collect distributed traces and metrics for application monitoring. For information about ADOT, see About AWS Distro for Open Telemetry. To set up ADOT with a high availability configuration, you must configure an ADOT collector container image and apply the external labels cluster and __replica__ to the AWS Prometheus remote write exporter. This exporter sends your scraped metrics to your Amazon Managed Service for Prometheus workspace via the remote_write endpoint. When you set these labels on the remote write exporter, you prevent duplicate metrics from being kept while redundant replicas run. For more information about the AWS Prometheus remote write exporter, High-availability data 77 Amazon Managed Service for Prometheus User Guide see Getting started with Prometheus remote write exporter for Amazon Managed Service for Prometheus. Note Certain versions of Kubernetes (1.28 and 1.29) |
amazon-managed-prometheus-user-guide-026 | amazon-managed-prometheus-user-guide.pdf | 26 | ADOT collector container image and apply the external labels cluster and __replica__ to the AWS Prometheus remote write exporter. This exporter sends your scraped metrics to your Amazon Managed Service for Prometheus workspace via the remote_write endpoint. When you set these labels on the remote write exporter, you prevent duplicate metrics from being kept while redundant replicas run. For more information about the AWS Prometheus remote write exporter, High-availability data 77 Amazon Managed Service for Prometheus User Guide see Getting started with Prometheus remote write exporter for Amazon Managed Service for Prometheus. Note Certain versions of Kubernetes (1.28 and 1.29) may emit their own metric with a cluster label. This can cause issues with Amazon Managed Service for Prometheus deduplication. See the High availability FAQ for more information. Send high availability data to Amazon Managed Service for Prometheus with the Prometheus community Helm chart To set up a high availability configuration with the Prometheus community Helm chart, you must apply external labels on all instances of a high availability group, so Amazon Managed Service for Prometheus can identify them. Here is an example of how you could add the external_labels to a single instance of Prometheus from the Prometheus community Helm chart. server: global: external_labels: cluster: monitoring-cluster __replica__: replica-1 Note If you want multiple replicas, you have to deploy the chart multiple times with different replica values, because the Prometheus community Helm chart does not let you dynamically set the replica value when increasing the number of replicas directly from the controller group. If you prefer to have the replica label auto-set, use the prometheus- operator Helm chart. Note Certain versions of Kubernetes (1.28 and 1.29) may emit their own metric with a cluster label. This can cause issues with Amazon Managed Service for Prometheus deduplication. See the High availability FAQ for more information. High-availability data 78 Amazon Managed Service for Prometheus User Guide Answers to common questions about high availability configuration in Amazon Managed Service for Prometheus Should I include the value __replica__ into another label to track the sample points? In a high availability setting, Amazon Managed Service for Prometheus ensures data samples are not duplicated by electing a leader in the cluster of Prometheus instances. If the leader replica stops sending data samples for 30 seconds, Amazon Managed Service for Prometheus automatically makes another Prometheus instance a leader replica and ingests data from the new leader, including any missed data. Therefore, the answer is no, it is not recommended. Doing so may cause issues like: • Querying a count in PromQL may return higher than expected value during the period of electing a new leader. • The number of active series gets increased during a period of electing a new leader and it reaches the active series limits. See AMP Quotas for more info. Kubernetes seems to have it's own cluster label, and is not deduplicating my metrics. How can I fix this? A new metric, apiserver_storage_size_bytes was introduced in Kubernetes 1.28, with a cluster label. This can cause issues with deduplication in Amazon Managed Service for Prometheus, which depends on the cluster label. In Kubernetes 1.3, the label is renamed to storage-cluster_id (it is also renamed in later patches of 1.28 and 1.29). If your cluster is emitting this metric with the cluster label, Amazon Managed Service for Prometheus can't dedupe the associated time series. We recommend you upgrade your Kubernetes cluster to the latest patched version to avoid this problem. Alternately, you can relabel the cluster label on your apiserver_storage_size_bytes metric before ingesting it into Amazon Managed Service for Prometheus. Note For more details about the change to Kubernetes, see Rename Label cluster to storage_cluster_id for apiserver_storage_size_bytes metric in the Kubernetes GitHub project. High-availability data 79 Amazon Managed Service for Prometheus User Guide Use cross Region workspaces to add high availability in Amazon Managed Service for Prometheus To add cross-Region availability to your data, you can send metrics to multiple workspaces across AWS Regions. Prometheus supports both multiple writers and cross-Region writing. The following example shows how to set up a Prometheus server running in Agent mode to send metrics to two workspaces in different Regions with Helm. extensions: sigv4auth: service: "aps" receivers: prometheus: config: scrape_configs: - job_name: 'kubernetes-kubelet' scheme: https tls_config: ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt insecure_skip_verify: true bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token kubernetes_sd_configs: - role: node relabel_configs: - action: labelmap regex: __meta_kubernetes_node_label_(.+) - target_label: __address__ replacement: kubernetes.default.svc.cluster.local:443 - source_labels: [__meta_kubernetes_node_name] regex: (.+) target_label: __metrics_path__ replacement: /api/v1/nodes/$${1}/proxy/metrics exporters: prometheusremotewrite/one: endpoint: "https://aps-workspaces.workspace_1_region.amazonaws.com/workspaces/ ws-workspace_1_id/api/v1/remote_write" auth: authenticator: sigv4auth prometheusremotewrite/two: High-availability data 80 Amazon Managed Service for Prometheus User Guide endpoint: "https://aps-workspaces.workspace_2_region.amazonaws.com/workspaces/ ws-workspace_2_id/api/v1/remote_write" auth: authenticator: sigv4auth service: extensions: [sigv4auth] pipelines: metrics/one: receivers: [prometheus] exporters: [prometheusremotewrite/one] metrics/two: receivers: [prometheus] exporters: [prometheusremotewrite/two] High-availability data 81 Amazon Managed Service for Prometheus User Guide Query your Prometheus metrics Now that metrics are being ingested to the workspace, you |
amazon-managed-prometheus-user-guide-027 | amazon-managed-prometheus-user-guide.pdf | 27 | scrape_configs: - job_name: 'kubernetes-kubelet' scheme: https tls_config: ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt insecure_skip_verify: true bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token kubernetes_sd_configs: - role: node relabel_configs: - action: labelmap regex: __meta_kubernetes_node_label_(.+) - target_label: __address__ replacement: kubernetes.default.svc.cluster.local:443 - source_labels: [__meta_kubernetes_node_name] regex: (.+) target_label: __metrics_path__ replacement: /api/v1/nodes/$${1}/proxy/metrics exporters: prometheusremotewrite/one: endpoint: "https://aps-workspaces.workspace_1_region.amazonaws.com/workspaces/ ws-workspace_1_id/api/v1/remote_write" auth: authenticator: sigv4auth prometheusremotewrite/two: High-availability data 80 Amazon Managed Service for Prometheus User Guide endpoint: "https://aps-workspaces.workspace_2_region.amazonaws.com/workspaces/ ws-workspace_2_id/api/v1/remote_write" auth: authenticator: sigv4auth service: extensions: [sigv4auth] pipelines: metrics/one: receivers: [prometheus] exporters: [prometheusremotewrite/one] metrics/two: receivers: [prometheus] exporters: [prometheusremotewrite/two] High-availability data 81 Amazon Managed Service for Prometheus User Guide Query your Prometheus metrics Now that metrics are being ingested to the workspace, you can query them. To create dashboards with visual representations of your metrics, you can use a service such as Amazon Managed Grafana. Amazon Managed Grafana (or a standalone instance of Grafana) can build a graphical interface that shows your metrics in a wide variety of display presentation styles. For more information about Amazon Managed Grafana see the Amazon Managed Grafana User Guide. You can also create one-off queries, explore your data, or write your own applications that use your metrics by using direct queries. Direct queries use the Amazon Managed Service for Prometheus API and the standard Prometheus query language, PromQL, to get data from your Prometheus workspace. For more information about PromQL and its syntax, see Querying Prometheus in the Prometheus documentation. Topics • Secure your metric queries • Set up Amazon Managed Grafana for use with Amazon Managed Service for Prometheus • Set up Grafana open source or Grafana Enterprise for use with Amazon Managed Service for Prometheus • Query using Grafana running in an Amazon EKS cluster • Query using Prometheus-compatible APIs • Get statistics about your query usage for each query Secure your metric queries Amazon Managed Service for Prometheus provides ways of helping you secure the querying of your metrics. Using AWS PrivateLink with Amazon Managed Service for Prometheus The network traffic for querying metrics in Amazon Managed Service for Prometheus can be done over a public internet endpoint, or by a VPC endpoint through AWS PrivateLink. When you use AWS PrivateLink, network traffic from your VPCs is secured within the AWS network without going over Secure your metric queries 82 Amazon Managed Service for Prometheus User Guide the public internet. To create an AWS PrivateLink VPC endpoint for Amazon Managed Service for Prometheus, see Using Amazon Managed Service for Prometheus with interface VPC endpoints. Authentication and authorization AWS Identity and Access Management is a web service that helps you securely control access to AWS resources. You use IAM to control who is authenticated (signed in) and authorized (has permissions) to use resources. Amazon Managed Service for Prometheus integrates with IAM to help you keep your data secure. When you set up Amazon Managed Service for Prometheus, you'll need to create some IAM roles that enable Grafana servers to query metrics stored in Amazon Managed Service for Prometheus workspaces. For more information about IAM, see What is IAM?. Another AWS security feature that can help you set up Amazon Managed Service for Prometheus is the AWS Signature Version 4 signing process (AWS SigV4). Signature Version 4 is the process to add authentication information to AWS requests sent by HTTP. For security, most requests to AWS must be signed with an access key, which consists of an access key ID and secret access key. These two keys are commonly referred to as your security credentials. For more information about SigV4, see Signature Version 4 signing process. Set up Amazon Managed Grafana for use with Amazon Managed Service for Prometheus Amazon Managed Grafana is a fully managed service for open-source Grafana that simplifies connecting to open-source, third-party ISV, and AWS services for visualizing and analyzing your data sources at scale. Amazon Managed Service for Prometheus supports using Amazon Managed Grafana to query metrics in a workspace. In the Amazon Managed Grafana console, you can add an Amazon Managed Service for Prometheus workspace as a data source by discovering your existing Amazon Managed Service for Prometheus accounts. Amazon Managed Grafana manages the configuration of the authentication credentials that are required to access Amazon Managed Service for Prometheus. For detailed instructions on creating a connection to Amazon Managed Service for Prometheus from Amazon Managed Grafana, see the instructions in the Amazon Managed Grafana User Guide. You may also view your Amazon Managed Service for Prometheus alerts in Amazon Managed Grafana. For instructions to set up integration with alerts, see Integrate alerts with Amazon Managed Grafana or open source Grafana. Authentication and authorization 83 Amazon Managed Service for Prometheus User Guide Connecting to Amazon Managed Grafana in a private VPC Amazon Managed Service for Prometheus provides a service endpoint for Amazon Managed Grafana to connect to when querying metrics and alerts. You can configure Amazon Managed Grafana to use a |
amazon-managed-prometheus-user-guide-028 | amazon-managed-prometheus-user-guide.pdf | 28 | for Prometheus from Amazon Managed Grafana, see the instructions in the Amazon Managed Grafana User Guide. You may also view your Amazon Managed Service for Prometheus alerts in Amazon Managed Grafana. For instructions to set up integration with alerts, see Integrate alerts with Amazon Managed Grafana or open source Grafana. Authentication and authorization 83 Amazon Managed Service for Prometheus User Guide Connecting to Amazon Managed Grafana in a private VPC Amazon Managed Service for Prometheus provides a service endpoint for Amazon Managed Grafana to connect to when querying metrics and alerts. You can configure Amazon Managed Grafana to use a private VPC (for details on setting up a private VPC in Grafana, see Connecting to Amazon VPC in the Amazon Managed Grafana User Guide). Depending on the settings, this VPC may not have access to the Amazon Managed Service for Prometheus service endpoint. To add Amazon Managed Service for Prometheus as a data source to an Amazon Managed Grafana workspace that is configured to use a specific private VPC, you must first connect your Amazon Managed Service for Prometheus to the same VPC by creating a VPC endpoint. For more information about creating a VPC endpoint, see Create an interface VPC endpoint for Amazon Managed Service for Prometheus. Set up Grafana open source or Grafana Enterprise for use with Amazon Managed Service for Prometheus You can use an instance of Grafana to query your metrics in Amazon Managed Service for Prometheus. This topic takes you through how to query metrics from Amazon Managed Service for Prometheus using a standalone instance of Grafana. Prerequisites Grafana instance – You must have a Grafana instance that is capable of authenticating with Amazon Managed Service for Prometheus. Amazon Managed Service for Prometheus supports the use of Grafana version 7.3.5 and later to query metrics in a workspace. Versions 7.3.5 and later include support for AWS Signature Version 4 (SigV4) authentication. To check your Grafana version, enter the following command, replacing grafana_install_directory with the path to your Grafana installation: grafana_install_directory/bin/grafana-server -v If you do not already have a standalone Grafana, or need a newer version, you can install a new instance. For instructions to set up a standalone Grafana, see Install Grafana in the Grafana Connecting to Amazon Managed Grafana in a private VPC 84 Amazon Managed Service for Prometheus User Guide documentation. For information about getting started with Grafana, see Getting started with Grafana in the Grafana documentation. AWS account – You must have an AWS account with the correct permissions to access your Amazon Managed Service for Prometheus metrics. To set up Grafana to work with Amazon Managed Service for Prometheus, you must be logged on to an account that has the AmazonPrometheusQueryAccess policy or the aps:QueryMetrics, aps:GetMetricMetadata, aps:GetSeries, and aps:GetLabelspermissions. For more information, see IAM permissions and policies. The next section describes setting up authentication from Grafana in more detail. Step 1: Set up AWS SigV4 Amazon Managed Service for Prometheus works with AWS Identity and Access Management (IAM) to secure all calls to Prometheus APIs with IAM credentials. By default, the Prometheus data source in Grafana assumes that Prometheus requires no authentication. To enable Grafana to take advantage of Amazon Managed Service for Prometheus authentication and authorization capabilities, you will need to enable SigV4 authentication support in the Grafana data source. Follow the steps on this page when you are using a self-managed Grafana open-source or a Grafana enterprise server. If you are using Amazon Managed Grafana, SIGv4 authentication is fully automated. For more information about Amazon Managed Grafana, see What is Amazon Managed Grafana? To enable SigV4 on Grafana, start Grafana with the AWS_SDK_LOAD_CONFIG and GF_AUTH_SIGV4_AUTH_ENABLED environment variables set to true. The GF_AUTH_SIGV4_AUTH_ENABLED environment variable overrides the default configuration for Grafana to enable SigV4 support. For more information, see Configuration in the Grafana documentation. Linux To enable SigV4 on a standalone Grafana server on Linux, enter the following commands. export AWS_SDK_LOAD_CONFIG=true export GF_AUTH_SIGV4_AUTH_ENABLED=true Step 1: Set up AWS SigV4 85 Amazon Managed Service for Prometheus User Guide cd grafana_install_directory ./bin/grafana-server Windows To enable SigV4 on a standalone Grafana on Windows using the Windows command prompt, enter the following commands. set AWS_SDK_LOAD_CONFIG=true set GF_AUTH_SIGV4_AUTH_ENABLED=true cd grafana_install_directory .\bin\grafana-server.exe Step 2: Add the Prometheus data source in Grafana The following steps explain how to set up the Prometheus data source in Grafana to query your Amazon Managed Service for Prometheus metrics. To add the Prometheus data source in your Grafana server 1. Open the Grafana console. 2. Under Configurations, choose Data sources. 3. Choose Add data source. 4. Choose Prometheus. 5. 6. For the HTTP URL, specify the Endpoint - query URL displayed in the workspace details page in the Amazon Managed Service for Prometheus console. In the HTTP URL that you just specified, remove the /api/v1/query string that is appended to the |
amazon-managed-prometheus-user-guide-029 | amazon-managed-prometheus-user-guide.pdf | 29 | Prometheus data source in Grafana The following steps explain how to set up the Prometheus data source in Grafana to query your Amazon Managed Service for Prometheus metrics. To add the Prometheus data source in your Grafana server 1. Open the Grafana console. 2. Under Configurations, choose Data sources. 3. Choose Add data source. 4. Choose Prometheus. 5. 6. For the HTTP URL, specify the Endpoint - query URL displayed in the workspace details page in the Amazon Managed Service for Prometheus console. In the HTTP URL that you just specified, remove the /api/v1/query string that is appended to the URL, because the Prometheus data source will automatically append it. The correct URL should look similar to https://aps-workspaces.us-west-2.amazonaws.com/ workspaces/ws-1234a5b6-78cd-901e-2fgh-3i45j6k178l9. Step 2: Add the Prometheus data source in Grafana 86 Amazon Managed Service for Prometheus User Guide 7. Under Auth, select the toggle for SigV4 Auth to enable it. 8. You can either configure SigV4 authorization by specifying your long-term credentials directly in Grafana, or by using a default provider chain. Specifying your long-term credentials directly gets you started quicker, and the following steps give those instructions first. Once you are more familiar with using Grafana with Amazon Managed Service for Prometheus, we recommend that you use a default provider chain, because it provides better flexibility and security. For more information about setting up your default provider chain, see Specifying Credentials. • To use your long-term credentials directly, do the following: a. Under SigV4 Auth Details, for Authentication Provider choose Access & secret key. b. c. d. e. For Access Key ID, enter your AWS access key ID. For Secret Access Key, enter your AWS secret access key. Leave the Assume Role ARN and External ID fields blank. For Default Region, choose the Region of your Amazon Managed Service for Prometheus workspace. This Region should match the Region contained in the URL that you listed in step 5. f. Choose Save & Test. You should see the following message: Data source is working The following screenshot shows the Access key, Secret key SigV4 auth detail setting. • To use a default provider chain instead (recommended for a production environment), do the following: Step 2: Add the Prometheus data source in Grafana 87 Amazon Managed Service for Prometheus User Guide a. Under SigV4 Auth Details, for Authentication Provider choose AWS SDK Default. b. c. Leave the Assume Role ARN and External ID fields blank. For Default Region, choose the Region of your Amazon Managed Service for Prometheus workspace. This Region should match the Region contained in the URL that you listed in step 5. d. Choose Save & Test. You should see the following message: Data source is working If you do not see that message, the next section provides troubleshooting tips for connecting. The following screenshot shows the SDK default SigV4 auth detail setting. 9. Test a PromQL query against the new data source: a. Choose Explore. b. Run a sample PromQL query such as: prometheus_tsdb_head_series Step 3: (optional) Troubleshooting if Save & Test doesn't work In the previous procedure, if you see an error when you choose Save & Test, check the following. HTTP Error Not Found Make sure that the workspace ID in the URL is correct. Step 3: (optional) Troubleshooting if Save & Test doesn't work 88 Amazon Managed Service for Prometheus HTTP Error Forbidden User Guide This error means that the credentials are not valid. Check the following: • Check that the Region specified in Default Region is correct. • Check your credential for typos. • Make sure that the credential that you are using has the AmazonPrometheusQueryAccess policy. For more information, see IAM permissions and policies. • Make sure that the credential that you are using has access to this Amazon Managed Service for Prometheus workspace. HTTP Error Bad Gateway Look at the Grafana server log to troubleshoot this error. For more information, see Troubleshooting in the Grafana documentation. If you see Error http: proxy error: NoCredentialProviders: no valid providers in chain, the default credential provider chain was not able to find a valid AWS credential to use. Make sure you have set up your credentials as documented in Specifying Credentials. If you want to use a shared configuration, make sure that the AWS_SDK_LOAD_CONFIG environment is set to true. Query using Grafana running in an Amazon EKS cluster Amazon Managed Service for Prometheus supports the use of Grafana version 7.3.5 and later to query metrics in a Amazon Managed Service for Prometheus workspace. Versions 7.3.5 and later include support for AWS Signature Version 4 (SigV4) authentication. To set up Grafana to work with Amazon Managed Service for Prometheus, you must be logged on to an account that has the AmazonPrometheusQueryAccess policy or the aps:QueryMetrics, aps:GetMetricMetadata, aps:GetSeries, and aps:GetLabels permissions. For more information, see IAM permissions and |
amazon-managed-prometheus-user-guide-030 | amazon-managed-prometheus-user-guide.pdf | 30 | a shared configuration, make sure that the AWS_SDK_LOAD_CONFIG environment is set to true. Query using Grafana running in an Amazon EKS cluster Amazon Managed Service for Prometheus supports the use of Grafana version 7.3.5 and later to query metrics in a Amazon Managed Service for Prometheus workspace. Versions 7.3.5 and later include support for AWS Signature Version 4 (SigV4) authentication. To set up Grafana to work with Amazon Managed Service for Prometheus, you must be logged on to an account that has the AmazonPrometheusQueryAccess policy or the aps:QueryMetrics, aps:GetMetricMetadata, aps:GetSeries, and aps:GetLabels permissions. For more information, see IAM permissions and policies. Set up AWS SigV4 Grafana has added a new feature to support AWS Signature Version 4 (SigV4) authentication. For more information, see Signature Version 4 signing process. This feature is not enabled by default Use Grafana in Amazon EKS 89 Amazon Managed Service for Prometheus User Guide on Grafana servers. The following instructions for enabling this feature assume that you are using Helm to deploy Grafana on a Kubernetes cluster. To enable SigV4 on your Grafana 7.3.5 or later server 1. Create a new update file to override your Grafana configuration, and name it amp_query_override_values.yaml. 2. Enter the following content into the file, and save the file. Replace account-id with the AWS account ID where the Grafana server is running. serviceAccount: name: "amp-iamproxy-query-service-account" annotations: eks.amazonaws.com/role-arn: "arn:aws:iam::account-id:role/amp-iamproxy- query-role" grafana.ini: auth: sigv4_auth_enabled: true In that YAML file content, amp-iamproxy-query-role is the name of the role that you will create in the next section, Set up IAM roles for service accounts. You can replace this role with your own role name if you already have a role created for querying your workspace. You will use this file later, in Upgrade the Grafana server using Helm. Set up IAM roles for service accounts If you are using a Grafana server in an Amazon EKS cluster, we recommend that you use IAM roles for service accounts, also known as service roles, for your access control. When you do this to associate an IAM role with a Kubernetes service account, the service account can then provide AWS permissions to the containers in any pod that uses that service account. For more information, see IAM roles for service accounts. If you have not already set up these service roles for querying, follow the instructions at Set up IAM roles for service accounts for the querying of metrics to set up the roles. You then need to add the Grafana service account in the conditions of the trust relationship. Set up IAM roles for service accounts 90 Amazon Managed Service for Prometheus User Guide To add the Grafana service account in the conditions of the trust relationship 1. From a terminal window, determine the namespace and the service account name for your Grafana server. For example, you could use the following command. kubectl get serviceaccounts -n grafana_namespace 2. In the Amazon EKS console, open the IAM role for service accounts that is associated with the EKS cluster. 3. Choose Edit trust relationship. 4. Update the Condition to include the Grafana namespace and the Grafana service account name that you found in the output of the command in step 1. The following is an example. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::account-id:oidc-provider/ oidc.eks.aws_region.amazonaws.com/id/openid" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "oidc.eks.region.amazonaws.com/id/openid:sub": [ "system:serviceaccount:aws-amp:amp-iamproxy-query-service-account", "system:serviceaccount:grafana-namespace:grafana-service-account-name" ] } } } ] } 5. Choose Update trust policy. Upgrade the Grafana server using Helm This step upgrades the Grafana server to use the entries that you added to the amp_query_override_values.yaml file in the previous section. Upgrade the Grafana server using Helm 91 Amazon Managed Service for Prometheus User Guide Run the following commands. For more information about Helm charts for Grafana, see Grafana Community Kubernetes Helm Charts. helm repo add grafana https://grafana.github.io/helm-charts helm upgrade --install grafana grafana/grafana -n grafana_namespace -f ./ amp_query_override_values.yaml Add the Prometheus data source in Grafana The following steps explain how to set up the Prometheus data source in Grafana to query your Amazon Managed Service for Prometheus metrics. To add the Prometheus data source in your Grafana server 1. Open the Grafana console. 2. Under Configurations, choose Data sources. 3. Choose Add data source. 4. Choose Prometheus. 5. 6. For the HTTP URL, specify the Endpoint - query URL displayed in the workspace details page in the Amazon Managed Service for Prometheus console. In the HTTP URL that you just specified, remove the /api/v1/query string that is appended to the URL, because the Prometheus data source will automatically append it. 7. Under Auth, select the toggle for SigV4 Auth to enable it. Leave the Assume Role ARN and External ID fields blank. Then for Default Region, select the Region where your Amazon Managed Service for Prometheus workspace is. 8. Choose Save & |
amazon-managed-prometheus-user-guide-031 | amazon-managed-prometheus-user-guide.pdf | 31 | data source. 4. Choose Prometheus. 5. 6. For the HTTP URL, specify the Endpoint - query URL displayed in the workspace details page in the Amazon Managed Service for Prometheus console. In the HTTP URL that you just specified, remove the /api/v1/query string that is appended to the URL, because the Prometheus data source will automatically append it. 7. Under Auth, select the toggle for SigV4 Auth to enable it. Leave the Assume Role ARN and External ID fields blank. Then for Default Region, select the Region where your Amazon Managed Service for Prometheus workspace is. 8. Choose Save & Test. You should see the following message: Data source is working 9. Test a PromQL query against the new data source: a. Choose Explore. b. Run a sample PromQL query such as: prometheus_tsdb_head_series Add the Prometheus data source in Grafana 92 Amazon Managed Service for Prometheus User Guide Query using Prometheus-compatible APIs Although using a tool such as Amazon Managed Grafana is the easiest way to view and query your metrics, Amazon Managed Service for Prometheus also supports several Prometheus- compatible APIs that you can use to query your metrics. For more information about all the available Prometheus-compatible APIs, see Prometheus-compatible APIs. The Prometheus-compatible APIs use the Prometheus query language, PromQL, to specify the data that you want to return. For details about PromQL and its syntax, see Querying Prometheus in the Prometheus documentation. When you use these APIs to query your metrics, the requests must be signed with the AWS Signature Version 4 signing process. You can set up AWS Signature Version 4 to simplify the signing process. For more information, see aws-sigv4-proxy. Signing through AWS SigV4 proxy can be performed using awscurl. The following topic Using awscurl to query Prometheus-compatible APIs walks you through using awscurl to set up AWS SigV4. Topics • Use awscurl to query with Prometheus-compatible APIs Use awscurl to query with Prometheus-compatible APIs API requests for Amazon Managed Service for Prometheus must be signed with SigV4. You can use awscurl to simplify the querying process. To install awscurl, you need to have Python 3 and pip package manager installed. On a Linux based instance, the following command installs awscurl. $ pip3 install awscurl On a macOS machine, the following command installs awscurl. $ brew install awscurl The following example is a sample awscurl query. Replace the Region, Workspace-id and QUERY inputs with appropriate values for your use case: Use direct queries 93 Amazon Managed Service for Prometheus User Guide # Define the Prometheus query endpoint URL. This can be found in the Amazon Managed Service for Prometheus console page # under the respective workspace. $ export AMP_QUERY_ENDPOINT=https://aps-workspaces.Region.amazonaws.com/ workspaces/Workspace-id/api/v1/query # credentials are infered from the default profile $ awscurl -X POST --region Region \ --service aps "${AMP_QUERY_ENDPOINT}" -d 'query=QUERY' --header 'Content-Type: application/x-www-form-urlencoded' Note Your query string must be url encoded. For a query like query=up, you could get results such as: { "status": "success", "data": { "resultType": "vector", "result": [ { "metric": { "__name__": "up", "instance": "localhost:9090", "job": "prometheus", "monitor": "monitor" }, "value": [ 1652452637.636, "1" ] }, ] } } Query with awscurl 94 Amazon Managed Service for Prometheus User Guide In order for awscurl to sign the provided requests, you will need to pass the valid credentials in one of the following ways: • Provide the access key ID and the Secret key for the IAM role. You can find the access key and the secret key for the role in the https://console.aws.amazon.com/iam/. For example: $ export AMP_QUERY_ENDPOINT=https://aps-workspaces.Region.amazonaws.com/ workspaces/Workspace_id/api/v1/query $ awscurl -X POST --region <Region> \ --access_key <ACCESS_KEY> \ --secret_key <SECRET_KEY> \ --service aps "$AMP_QUERY_ENDPOINT?query=<QUERY>" • Reference the configuration files stored in the .aws/credentials and /aws/config file. You can also choose to specify the name of the profile to be used. If unspecified, the default file will be used. For example: $ export AMP_QUERY_ENDPOINT=https://aps-workspaces.<Region>.amazonaws.com/workspaces/ <Workspace_ID>/api/v1/query $ awscurl -X POST --region <Region> \ --profile <PROFILE_NAME> --service aps "$AMP_QUERY_ENDPOINT?query=<QUERY>" • Use the instance profile associated with the EC2 instance. Executing query requests using awscurl container When installing a different version of Python and the associated dependencies is not feasible, a container can be used to package the awscurl application and its dependencies. The following example uses a Docker runtime to deploy awscurl, but any OCI compliant runtime and image will work. $ docker pull okigan/awscurl $ export AMP_QUERY_ENDPOINT=https://aps-workspaces.Region.amazonaws.com/ workspaces/Workspace_id/api/v1/query Query with awscurl 95 Amazon Managed Service for Prometheus User Guide $ docker run --rm -it okigan/awscurl --access_key $AWS_ACCESS_KEY_ID --secret_key $AWS_SECRET_ACCESS_KEY \ --region Region --service aps "$AMP_QUERY_ENDPOINT? query=QUERY" Get statistics about your query usage for each query Query pricing is based on the total number of query samples processed in a month from executed queries. You can get statistics about each query that you make to keep track of your samples processed. The query response for |
amazon-managed-prometheus-user-guide-032 | amazon-managed-prometheus-user-guide.pdf | 32 | uses a Docker runtime to deploy awscurl, but any OCI compliant runtime and image will work. $ docker pull okigan/awscurl $ export AMP_QUERY_ENDPOINT=https://aps-workspaces.Region.amazonaws.com/ workspaces/Workspace_id/api/v1/query Query with awscurl 95 Amazon Managed Service for Prometheus User Guide $ docker run --rm -it okigan/awscurl --access_key $AWS_ACCESS_KEY_ID --secret_key $AWS_SECRET_ACCESS_KEY \ --region Region --service aps "$AMP_QUERY_ENDPOINT? query=QUERY" Get statistics about your query usage for each query Query pricing is based on the total number of query samples processed in a month from executed queries. You can get statistics about each query that you make to keep track of your samples processed. The query response for a query or a queryRange API can include the statistics data about query samples processed by including the query parameter stats=all in the request. A samples object is created in the stats object and the stats data is returned in the response. The samples object consists of the following attributes: Attribute Description totalQueryableSamples Total number of query samples processed. This is the information to be used for billing. totalQueryableSamp lesPerStep The number of query samples processed per each step. This is structured as an array of arrays with the timestamp in epoch and the number of samples loaded on the specific step. Sample requests and responses that include the stats information in the response are as follows: Example for query: GET endpoint/api/v1/query?query=up&time=1652382537&stats=all Response { "status": "success", "data": { "resultType": "vector", Query statistics 96 User Guide Amazon Managed Service for Prometheus "result": [ { "metric": { "__name__": "up", "instance": "localhost:9090", "job": "prometheus" }, "value": [ 1652382537, "1" ] } ], "stats": { "timings": { "evalTotalTime": 0.00453349, "resultSortTime": 0, "queryPreparationTime": 0.000019363, "innerEvalTime": 0.004508405, "execQueueTime": 0.000008786, "execTotalTime": 0.004554219 }, "samples": { "totalQueryableSamples": 1, "totalQueryableSamplesPerStep": [ [ 1652382537, 1 ] ] } } } } Example for queryRange: GET endpoint/api/v1/query_range?query=sum+%28rate+%28go_gc_duration_seconds_count%5B1m%5D %29%29&start=1652382537&end=1652384705&step=1000&stats=all Response Query statistics 97 Amazon Managed Service for Prometheus User Guide { "status": "success", "data": { "resultType": "matrix", "result": [ { "metric": {}, "values": [ [ 1652383000, "0" ], [ 1652384000, "0" ] ] } ], "stats": { "samples": { "totalQueryableSamples": 8, "totalQueryableSamplesPerStep": [ [ 1652382000, 0 ], [ 1652383000, 4 ], [ 1652384000, 4 ] ] } } } } Query statistics 98 Amazon Managed Service for Prometheus User Guide Using rules to modify or monitor metrics as they are received You can set up rules to act upon metrics as they are received by Amazon Managed Service for Prometheus. These rules can monitor the metrics or even create new, computed, metrics based on the metrics received. Amazon Managed Service for Prometheus supports two types of rules that it evaluates at regular intervals: • Recording rules allow you to precompute frequently needed or computationally expensive expressions and save their results as a new set of time series. Querying the precomputed result is often much faster than running the original expression every time it is needed. • Alerting rules allow you to define alert conditions based on PromQL and a threshold. When the rule triggers the threshold, a notification is sent to alert manager, which can be configured to managed the rules, or forward them to notification downstream to receivers such as Amazon Simple Notification Service. To use rules in Amazon Managed Service for Prometheus, you create one or more YAML rules files that define the rules. An Amazon Managed Service for Prometheus rules file has the same format as a rules file in standalone Prometheus. For more information, see Defining Recording rules and Alerting rules in the Prometheus documentation. You can have multiple rules files in a workspace. Each separate rules file is contained within a separate namespace. Having multiple rules files lets you import existing Prometheus rules files to a workspace without having to change or combine them. Different rule group namespaces can also have different tags. Rule sequencing Within a rules file, rules are contained within rules groups. Rules within a single rules group in a rules file are always evaluated in order from top to bottom. Therefore, in recording rules, the result of one recording rule can be used in the computation of a later recording rule or in an alerting rule in the same rule group. However, because you can't specify the order in which to run separate rules files, you can't use the results from one recording rule to compute a rule in a different rule group or a different rules file. 99 Amazon Managed Service for Prometheus User Guide Topics • Understanding IAM permissions needed for using rules • Create a rules file • Upload a rules configuration file to Amazon Managed Service for Prometheus • Edit or replace a rules configuration file • Troubleshooting Ruler Understanding IAM permissions needed for using rules You must give users permissions to use rules in Amazon Managed Service for Prometheus. Create an AWS Identity and Access Management (IAM) policy |
amazon-managed-prometheus-user-guide-033 | amazon-managed-prometheus-user-guide.pdf | 33 | rules files, you can't use the results from one recording rule to compute a rule in a different rule group or a different rules file. 99 Amazon Managed Service for Prometheus User Guide Topics • Understanding IAM permissions needed for using rules • Create a rules file • Upload a rules configuration file to Amazon Managed Service for Prometheus • Edit or replace a rules configuration file • Troubleshooting Ruler Understanding IAM permissions needed for using rules You must give users permissions to use rules in Amazon Managed Service for Prometheus. Create an AWS Identity and Access Management (IAM) policy with the following permissions, and assign the policy to your users, groups, or roles. Note For more information about IAM, see Identity and Access Management for Amazon Managed Service for Prometheus. Policy to give access to use rules The following policy gives access to use rules for all resources in your account. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "aps: CreateRuleGroupsNamespace", "aps: ListRuleGroupsNamespaces", "aps: DescribeRuleGroupsNamespace", "aps: PutRuleGroupsNamespace", "aps: DeleteRuleGroupsNamespace", ], "Resource": "*" } ] Necessary IAM permissions 100 Amazon Managed Service for Prometheus User Guide } Policy to give access to only one namespace You can also create policy that gives access to only specific policies. The following sample policy gives access only to the RuleGroupNamespace specified. To use this policy, replace <account>, <region>, <workspace-id>, and <namespace-name> with appropriate values for your account. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "aps:ListRules", "aps:ListTagsForResource", "aps:GetLabels", "aps:CreateRuleGroupsNamespace", "aps:ListRuleGroupsNamespaces", "aps:DescribeRuleGroupsNamespace", "aps:PutRuleGroupsNamespace", "aps:DeleteRuleGroupsNamespace" ], "Resource": [ "arn:aws:aps:*:<account>:workspace/*", "arn:aws:aps:<region>:<account>:rulegroupnamespace/<workspace- id>/<namespace-name>" ] } ] } Create a rules file To use rules in Amazon Managed Service for Prometheus, you create a rules file that defines the rules. An Amazon Managed Service for Prometheus rules file is a YAML text file that has the same format as a rules file in standalone Prometheus. For more information, see Defining Recording rules and Alerting rules in the Prometheus documentation. The following is a basic example of a rules file: Create a rules file 101 Amazon Managed Service for Prometheus User Guide groups: - name: cpu_metrics rules: - record: avg_cpu_usage expr: avg(rate(node_cpu_seconds_total[5m])) by (instance) - alert: HighAverageCPU expr: avg_cpu_usage > 0.8 for: 10m keep_firing_for: 20m labels: severity: critical annotations: summary: "Average CPU usage across cluster is too high" This simple example creates a new metric using a recording rule, called avg_cpu_usage and then uses that in an alert. The following describes some of the properties used. For more information about alerting rules and other properties you can include, see Alerting rules in the Prometheus documentation. • record: avg_cpu_usage – This recording rule creates a new metric called avg_cpu_usage. • expr: avg(rate(node_cpu_seconds_total[5m])) by (instance) – This expression for the recording rule calculates the average rate of CPU usage over the last 5 minutes for each node, grouping by the instance label. • alert: HighAverageCPU – This alert rule creates a new alert called HighAverageCPU • expr: avg_cpu_usage > 0.8 – This expression tells the alert to look for samples where the average CPU usage goes over 80%. • for: 10m – The alert will fire when the expression is met for 10 minutes. In this case, the samples are an average over 5 minutes, so the alert will fire when it receives at least 2 samples that are over the threshold. • keep_firing_for: 20m – This alert will continue to fire until the samples are below the threshold for at least 20 minutes. This can be useful to avoid the alert going up and down repeatedly in succession. For more alerting rule examples, see Alerting rule examples. Create a rules file 102 Amazon Managed Service for Prometheus User Guide Note You can create a rules definition file locally and then upload it to Amazon Managed Service for Prometheus, or you can create, edit and upload the definition directly within the Amazon Managed Service for Prometheus console. Either way, the same formatting rules apply. To learn more about uploading and editing your file, see Upload a rules configuration file to Amazon Managed Service for Prometheus. Upload a rules configuration file to Amazon Managed Service for Prometheus Once you know what rules you want in your rules configuration file, you can either create and edit it within the console, or you can upload a file with the console or AWS CLI. Note If you are running an Amazon EKS cluster, you can also upload a rule configuration file using AWS Controllers for Kubernetes. To use the Amazon Managed Service for Prometheus console to edit or replace your rules configuration and create the namespace 1. Open the Amazon Managed Service for Prometheus console at https:// console.aws.amazon.com/prometheus/. 2. In the upper left corner of the page, choose the menu icon, and then choose All workspaces. 3. Choose the workspace ID |
amazon-managed-prometheus-user-guide-034 | amazon-managed-prometheus-user-guide.pdf | 34 | file, you can either create and edit it within the console, or you can upload a file with the console or AWS CLI. Note If you are running an Amazon EKS cluster, you can also upload a rule configuration file using AWS Controllers for Kubernetes. To use the Amazon Managed Service for Prometheus console to edit or replace your rules configuration and create the namespace 1. Open the Amazon Managed Service for Prometheus console at https:// console.aws.amazon.com/prometheus/. 2. In the upper left corner of the page, choose the menu icon, and then choose All workspaces. 3. Choose the workspace ID of the workspace, and then choose the Rules management tab. 4. Choose Add namespace. 5. Choose Choose file, and select the rules definition file. Alternately, you can create and edit a rules definition file directly in the Amazon Managed Service for Prometheus console by selecting Define configuration. This will create a sample default definition file that you edit before uploading. 6. (Optional) To add tags to the namespace, choose Add new tag. Then, for Key, enter a name for the tag. You can add an optional value for the tag in Value. Upload a rules file 103 Amazon Managed Service for Prometheus User Guide To add another tag, choose Add new tag. 7. Choose Continue. Amazon Managed Service for Prometheus creates a new namespace with the same name as the rules file that you selected. To use the AWS CLI to upload an alert manager configuration to a workspace in a new namespace 1. Base64 encode the contents of your alert manager file. On Linux, you can use the following command: base64 input-file output-file On macOS, you can use the following command: openssl base64 input-file output-file 2. Enter one of the following commands to create the namespace and upload the file. On AWS CLI version 2, enter: aws amp create-rule-groups-namespace --data file://path_to_base_64_output_file -- name namespace-name --workspace-id my-workspace-id --region region On AWS CLI version 1, enter: aws amp create-rule-groups-namespace --data fileb://path_to_base_64_output_file -- name namespace-name --workspace-id my-workspace-id --region region 3. It takes a few seconds for your alert manager configuration to become active. To check the status, enter the following command: aws amp describe-rule-groups-namespace --workspace-id workspace_id -- name namespace-name --region region If the status is ACTIVE, your rules file has taken effect. Upload a rules file 104 Amazon Managed Service for Prometheus User Guide Edit or replace a rules configuration file If you want to change the rules in a rule file that you have already uploaded to Amazon Managed Service for Prometheus, you can either upload a new rules file to replace the existing configuration, or you can edit the current configuration directly in the console. Optionally, you can download the current file, edit it in a text editor, then upload the new version. To use the Amazon Managed Service for Prometheus console to edit your rules configuration 1. Open the Amazon Managed Service for Prometheus console at https:// console.aws.amazon.com/prometheus/. 2. In the upper left corner of the page, choose the menu icon, and then choose All workspaces. 3. Choose the workspace ID of the workspace, and then choose the Rules management tab. 4. 5. Select the name of the rules configuration file that you want to edit. (Optional) If you want to download the current rules configuration file, choose Download or Copy. 6. Choose Modify to edit the configuration directly within the console. Choose Save when complete. Alternately, you can choose Replace configuration to upload a new configuration file. If so, select the new rules definition file, and choose Continue to upload it. To use the AWS CLI to edit a rules configuration file 1. Base64 encode the contents of your rules file. On Linux, you can use the following command: base64 input-file output-file On macOS, you can use the following command: openssl base64 input-file output-file 2. Enter one of the following commands to upload the new file. On AWS CLI version 2, enter: Edit a rules file 105 Amazon Managed Service for Prometheus User Guide aws amp put-rule-groups-namespace --data file://path_to_base_64_output_file -- name namespace-name --workspace-id my-workspace-id --region region On AWS CLI version 1, enter: aws amp put-rule-groups-namespace --data fileb://path_to_base_64_output_file -- name namespace-name --workspace-id my-workspace-id --region region 3. It takes a few seconds for your rules file to become active. To check the status, enter the following command: aws amp describe-rule-groups-namespace --workspace-id workspace_id -- name namespace-name --region region If the status is ACTIVE, your rules file has taken effect. Until then, the previous version of this rules file is still active. Troubleshooting Ruler Using Monitor Amazon Managed Service for Prometheus events with CloudWatch Logs, you can troubleshoot Alert Manager and Ruler related issues. This section contains ruler related troubleshooting topics. When the log contains the following ruler failure error { "workspaceId": "ws-12345c67-89c0-4d12-345b-f14db70f7a99", "message": { "log": "Evaluating rule failed, name=failure, group=canary_long_running_vl_namespace, namespace=canary_long_running_vl_namespace, |
amazon-managed-prometheus-user-guide-035 | amazon-managed-prometheus-user-guide.pdf | 35 | few seconds for your rules file to become active. To check the status, enter the following command: aws amp describe-rule-groups-namespace --workspace-id workspace_id -- name namespace-name --region region If the status is ACTIVE, your rules file has taken effect. Until then, the previous version of this rules file is still active. Troubleshooting Ruler Using Monitor Amazon Managed Service for Prometheus events with CloudWatch Logs, you can troubleshoot Alert Manager and Ruler related issues. This section contains ruler related troubleshooting topics. When the log contains the following ruler failure error { "workspaceId": "ws-12345c67-89c0-4d12-345b-f14db70f7a99", "message": { "log": "Evaluating rule failed, name=failure, group=canary_long_running_vl_namespace, namespace=canary_long_running_vl_namespace, err=found duplicate series for the match group {dimension1=\\\"1\\\"} on the right hand-side of the operation: [{__name__=\\\"fake_metric2\\\", dimension1=\\\"1\\ \", dimension2=\\\"b\\\"}, {__name__=\\\"fake_metric2\\\", dimension1=\\\"1\\\", dimension2=\\\"a\\\"}];many-to-many matching not allowed: matching labels must be unique on one side", "level": "ERROR", "name": "failure", "group": "canary_long_running_vl_namespace", Troubleshooting Ruler 106 Amazon Managed Service for Prometheus User Guide "namespace": "canary_long_running_vl_namespace" }, "component": "ruler" } This means that some error occurred while executing the rule. Action to take Use the error message to troubleshoot the rule execution. Troubleshooting Ruler 107 Amazon Managed Service for Prometheus User Guide Managing and forwarding alerts in Amazon Managed Service for Prometheus with alert manager When the alerting rules that Amazon Managed Service for Prometheus runs are firing, alert manager handles the alerts that are sent. It deduplicates, groups, and routes the alerts to downstream receivers. Amazon Managed Service for Prometheus supports only Amazon Simple Notification Service as a receiver, and can route messages to Amazon SNS topics in the same account. You can also use alert manager to silence and inhibit alerts. Alert manager provides similar functionality to Alertmanager in Prometheus. You can use alert manager's configuration file for the following: • Grouping – Grouping collects similar alerts into a single notification. This is especially useful during larger outages when many systems fail at once and hundreds of alerts might fire simultaneously. For example, suppose that a network failure causes many of your nodes to fail at the same time. If these types of alerts are grouped, alert manager sends you a single notification. Alert grouping and the timing for the grouped notifications are configured by a routing tree in the alert manager configuration file. For more information, see <route>. • Inhibition – Inhibition suppresses notifications for certain alerts if certain other alerts are already firing. For example, if an alert is firing about a cluster being unreachable, you can configure alert manager to mute all other alerts concerning this cluster. This prevents notifications for hundreds or thousands of firing alerts that are unrelated to the actual issue. For more information about how to write inhibition rules, see <inhibit_rule>. • Silences – Silences mute alerts for a specified time, such as during a maintenance window. Incoming alerts are checked for whether they match all the equality or regular expression matchers of an active silence. If they do, no notifications are sent for that alert. To create a silence, you use the PutAlertManagerSilences API. For more information, see PutAlertManagerSilences. Prometheus templating Standalone Prometheus supports templating, using separate template files. Templates can use conditionals and format data, among other things. 108 Amazon Managed Service for Prometheus User Guide In Amazon Managed Service for Prometheus, you put your templating in the same alert manager configuration file as your alert manager configuration. Topics • Understanding IAM permissions needed for working with alert manager • Create an alert manager configuration in Amazon Managed Service for Prometheus to manage and route alerts • Forward alerts to an alert receiver with alert manager in Amazon Managed Service for Prometheus • Upload your alert manager configuration file to Amazon Managed Service for Prometheus • Integrate alerts with Amazon Managed Grafana or open source Grafana • Troubleshoot alert manager with CloudWatch Logs Understanding IAM permissions needed for working with alert manager You must give users permissions to use alert manager in Amazon Managed Service for Prometheus. Create an AWS Identity and Access Management (IAM) policy with the following permissions, and assign the policy to your users, groups, or roles. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "aps: CreateAlertManagerDefinition", "aps: DescribeAlertManagerSilence", "aps: DescribeAlertManagerDefinition", "aps: PutAlertManagerDefinition", "aps: DeleteAlertManagerDefinition", "aps: ListAlerts", "aps: ListRules", "aps: ListAlertManagerReceivers", "aps: ListAlertManagerSilences", "aps: ListAlertManagerAlerts", "aps: ListAlertManagerAlertGroups", "aps: GetAlertManagerStatus", Necessary IAM permissions 109 Amazon Managed Service for Prometheus User Guide "aps: GetAlertManagerSilence", "aps: PutAlertManagerSilences", "aps: DeleteAlertManagerSilence", "aps: CreateAlertManagerAlerts" ], "Resource": "*" } ] } Create an alert manager configuration in Amazon Managed Service for Prometheus to manage and route alerts To use alert manager and templating in Amazon Managed Service for Prometheus, you create an alert manager configuration YAML file. An Amazon Managed Service for Prometheus alert manager file has two main sections: • template_files: contains the templates used for messages sent by receivers. For more information, see Template |
amazon-managed-prometheus-user-guide-036 | amazon-managed-prometheus-user-guide.pdf | 36 | "aps: ListAlertManagerReceivers", "aps: ListAlertManagerSilences", "aps: ListAlertManagerAlerts", "aps: ListAlertManagerAlertGroups", "aps: GetAlertManagerStatus", Necessary IAM permissions 109 Amazon Managed Service for Prometheus User Guide "aps: GetAlertManagerSilence", "aps: PutAlertManagerSilences", "aps: DeleteAlertManagerSilence", "aps: CreateAlertManagerAlerts" ], "Resource": "*" } ] } Create an alert manager configuration in Amazon Managed Service for Prometheus to manage and route alerts To use alert manager and templating in Amazon Managed Service for Prometheus, you create an alert manager configuration YAML file. An Amazon Managed Service for Prometheus alert manager file has two main sections: • template_files: contains the templates used for messages sent by receivers. For more information, see Template Reference and Template Examples in the Prometheus documentation. • alertmanager_config: contains the alert manager configuration. This uses the same structure as an alert manager config file in standalone Prometheus. For more information, see Configuration in the Alertmanager documentation. Note The repeat_interval configuration described in the Prometheus documentation above has an additional limitation in Amazon Managed Service for Prometheus. The maximum allowed value is five days. If you set it higher than five days, it will be treated as five days and notifications will be sent again after the five day period has passed. Note You can also edit the configuration file directly in the Amazon Managed Service for Prometheus console, but it must still follow the format specified here. For more information on uploading or editing a configuration file, see Upload your alert manager configuration file to Amazon Managed Service for Prometheus. Create a configuration file 110 Amazon Managed Service for Prometheus User Guide In Amazon Managed Service for Prometheus, your alert manager configuration file must have all your alert manager configuration content inside of an alertmanager_config key at the root of the YAML file. The following is a basic example alert manager configuration file: alertmanager_config: | route: receiver: 'default' receivers: - name: 'default' sns_configs: - topic_arn: arn:aws:sns:us-east-2:123456789012:My-Topic sigv4: region: us-east-2 attributes: key: key1 value: value1 The only receiver currently supported is Amazon Simple Notification Service (Amazon SNS). If you have other types of receivers listed in the configuration, it will be rejected. Here is another sample alert manager configuration file that uses both the template_files block and the alertmanager_config block. template_files: default_template: | {{ define "sns.default.subject" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}]{{ end }} {{ define "__alertmanager" }}AlertManager{{ end }} {{ define "__alertmanagerURL" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver | urlquery }}{{ end }} alertmanager_config: | global: templates: - 'default_template' route: receiver: default receivers: - name: 'default' sns_configs: - topic_arn: arn:aws:sns:us-east-2:accountid:My-Topic Create a configuration file 111 Amazon Managed Service for Prometheus User Guide sigv4: region: us-east-2 attributes: key: severity value: SEV2 Default Amazon SNS template block The default Amazon SNS configuration uses the following template unless you explicitly override it. {{ define "sns.default.message" }}{{ .CommonAnnotations.SortedPairs.Values | join " " }} {{ if gt (len .Alerts.Firing) 0 -}} Alerts Firing: {{ template "__text_alert_list" .Alerts.Firing }} {{- end }} {{ if gt (len .Alerts.Resolved) 0 -}} Alerts Resolved: {{ template "__text_alert_list" .Alerts.Resolved }} {{- end }} {{- end }} Forward alerts to an alert receiver with alert manager in Amazon Managed Service for Prometheus When an alert is raised by an alert rule, it is sent to alert manager. Alert manager performs functions such as deduplicating alerts, inhibiting alerts during maintenance, or grouping them as needed. It then forwards the alert as a message to an alert receiver. You can set up an alert receiver that can notify operators, have automated responses, or respond to the alerts in other ways. The only alert receiver supported in Amazon Managed Service for Prometheus is Amazon Simple Notification Service (Amazon SNS). For more information, see What is Amazon SNS?. Amazon SNS can be used to respond to alerts in a wide variety of ways, including forwarding to other systems, such as email, SMS, or HTTP endpoints. The following topics describe the tasks associated with creating and configuring your Amazon SNS alert receiver. Topics Set up an alert receiver 112 Amazon Managed Service for Prometheus User Guide • Creating a new Amazon SNS topic for use as an alert receiver in Amazon Managed Service for Prometheus • Giving Amazon Managed Service for Prometheus permission to send alert messages to your Amazon SNS topic • Configure alert manager to send messages to your Amazon SNS topic • Configure alert manager to send messages to Amazon SNS as JSON • Configure Amazon SNS to send messages for alerts to other destinations • Understanding Amazon SNS message validation rules Creating a new Amazon SNS topic for use as an alert receiver in Amazon Managed Service for Prometheus You can use an existing Amazon SNS topic as an alert receiver for Amazon Managed Service for Prometheus, or you can create a new one. We recommend that you use a topic of |
amazon-managed-prometheus-user-guide-037 | amazon-managed-prometheus-user-guide.pdf | 37 | messages to your Amazon SNS topic • Configure alert manager to send messages to your Amazon SNS topic • Configure alert manager to send messages to Amazon SNS as JSON • Configure Amazon SNS to send messages for alerts to other destinations • Understanding Amazon SNS message validation rules Creating a new Amazon SNS topic for use as an alert receiver in Amazon Managed Service for Prometheus You can use an existing Amazon SNS topic as an alert receiver for Amazon Managed Service for Prometheus, or you can create a new one. We recommend that you use a topic of the Standard type, so that you can forward alerts from the topic to email, SMS, or HTTP. To create a new Amazon SNS topic to use as your alert manager receiver, follow the steps in Step 1: Create a topic. Be sure to choose Standard for the topic type. If you want to receive emails every time a message is sent to that Amazon SNS topic, follow the steps in Step 2: Create a subscription to the topic. Whether you use a new or existing Amazon SNS topic, you will need the Amazon Resource Name (ARN) of your Amazon SNS topic to complete the following tasks. Giving Amazon Managed Service for Prometheus permission to send alert messages to your Amazon SNS topic You must give Amazon Managed Service for Prometheus permission to send messages to your Amazon SNS topic. The following policy statement will give that permission. It includes a Condition statement to help prevent a security problem known as the confused deputy problem. The Condition statement restricts access to the Amazon SNS topic to allow only operations coming from this specific account and Amazon Managed Service for Prometheus workspace. For more information about the confused deputy problem, see Cross-service confused deputy prevention. Create Amazon SNS topic 113 Amazon Managed Service for Prometheus User Guide To give Amazon Managed Service for Prometheus permission to send messages to your Amazon SNS topic 1. Open the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home. 2. In the navigation pane, choose Topics. 3. Choose the name of the topic that you are using with Amazon Managed Service for Prometheus. 4. Choose Edit. 5. Choose Access policy and add the following policy statement to the existing policy. { "Sid": "Allow_Publish_Alarms", "Effect": "Allow", "Principal": { "Service": "aps.amazonaws.com" }, "Action": [ "sns:Publish", "sns:GetTopicAttributes" ], "Condition": { "ArnEquals": { "aws:SourceArn": "workspace_ARN" }, "StringEquals": { "AWS:SourceAccount": "account_id" } }, "Resource": "arn:aws:sns:region:account_id:topic_name" } [Optional] If your Amazon SNS topic is service side encryption (SSE) enabled, you need to allow Amazon Managed Service for Prometheus to send messages to this encrypted topic by adding the kms:GenerateDataKey* and kms:Decrypt permissions to the AWS KMS key policy of the key used to encrypt the topic. For example, you could add the following to the policy: { "Statement": [{ Amazon SNS permissions needed 114 Amazon Managed Service for Prometheus User Guide "Effect": "Allow", "Principal": { "Service": "aps.amazonaws.com" }, "Action": [ "kms:GenerateDataKey*", "kms:Decrypt" ], "Resource": "*" }] } For more information, see AWS KMS Permissions for SNS Topic. 6. Choose Save changes. Note By default, Amazon SNS creates the access policy with condition on AWS:SourceOwner. For more information, see SNS Access Policy. Note IAM follows the Most-restrictive policy first rule. In your SNS topic, if there is a policy block that is more restrictive than the documented Amazon SNS policy block, the permission for the topic policy is not granted. To evaluate your policy and find out what's been granted, see Policy evaluation logic. Cross-service confused deputy prevention The confused deputy problem is a security issue where an entity that doesn't have permission to perform an action can coerce a more-privileged entity to perform the action. In AWS, cross-service impersonation can result in the confused deputy problem. Cross-service impersonation can occur when one service (the calling service) calls another service (the called service). The calling service can be manipulated to use its permissions to act on another customer's resources in a way it should not otherwise have permission to access. To prevent this, AWS provides tools that help you protect Amazon SNS permissions needed 115 Amazon Managed Service for Prometheus User Guide your data for all services with service principals that have been given access to resources in your account. We recommend using the aws:SourceArn and aws:SourceAccount global condition context keys in resource policies to limit the permissions that Amazon Managed Service for Prometheus gives to Amazon SNS to the resource. If you use both global condition context keys, the aws:SourceAccount value and the account in the aws:SourceArn value must use the same account ID when used in the same policy statement. The value of aws:SourceArn must be the ARN of the Amazon Managed Service for Prometheus workspace. The most effective way to protect against the confused |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.