Monday, 24 February 2020

Introduction To Machine Learning Using Python

What is the Machine Learning?

Machine learning is the scientific study of algorithms and statistical models that computer systems use to perform a specific task without using explicit instructions, relying on patterns and inference instead. It is seen as a subset of artificial intelligence (AI).


Introduction To Docker

What is a Docker?

Docker is a open source tool to make easier to create, deploy, and run application by using containers. Container allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.

Using Amazon SQS with the AWS CLI - Part 9

You can access the features of Amazon Simple Queue Service (Amazon SQS) using the AWS Command Line Interface (AWS CLI).

Before you run any commands, set your default credentials. For more information, see Configuring the AWS CLI.

Create Queue

Creates a new standard or FIFO queue. You can pass one or more attributes in the request. Keep the following caveats in mind:
  • If you don't specify the FifoQueue attribute, Amazon SQS creates a standard queue.
  • If you don't provide a value for an attribute, the queue is created with the default value for the attribute. 
  • If you delete a queue, you must wait at least 60 seconds before creating a queue with the same name. 
  create-queue
--queue-name <value>
[--attributes <value>]
[--tags <value>]
[--cli-input-json <value>] 
$ aws sqs create-queue --queue-name test-queue
{
    "QueueUrl": "https://ap-south-1.queue.amazonaws.com/23456789012/test-queue"
}

Delete Queue

Deletes the specified message from the specified queue. To select the message to delete, use the ReceiptHandle of the message (not the MessageId which you receive when you send the message). Amazon SQS can delete a message from a queue even if a visibility timeout setting causes the message to be locked by another consumer. Amazon SQS automatically deletes messages left in a queue longer than the retention period configured for the queue.
  delete-message
--queue-url <value>
--receipt-handle <value>
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]


Sunday, 23 February 2020

Using Amazon S3 with the AWS CLI - Part 8

You can access the features of Amazon Simple Storage Service (Amazon S3) using the AWS Command Line Interface (AWS CLI). 

Before you run any commands, set your default credentials. For more information, see Configuring the AWS CLI. 

The AWS CLI provides two tiers of commands for accessing Amazon S3: 

  • The s3 tier consists of high-level commands that simplify performing common tasks, such as creating, manipulating, and deleting objects and buckets. 
  • The s3api tier behaves identically to other AWS services by exposing direct access to all Amazon S3 API operations. It enables you to carry out advanced operations that might not be possible with the following tier's high-level commands alone. 

To get a list of all of the commands available in each tier, use the help argument with the aws s3api or aws s3 commands. 
$ aws s3 help
$ aws s3api help

Using High-Level (s3) Commands with the AWS CLI


This topic describes how you can manage Amazon S3 buckets and objects using high-level aws s3 commands.

Before you run any commands, set your default credentials. For more information, see Configuring the AWS CLI.

Manage Buckets

High-level aws s3 commands support common bucket operations, such as creating, listing, and deleting buckets.

Create a Bucket

Use the s3 mb command to create a bucket. Bucket names must be globally unique and should be DNS compliant. Bucket names can contain lowercase letters, numbers, hyphens, and periods. Bucket names can start and end only with a letter or number, and cannot contain a period next to a hyphen or another period.

$ aws s3 mb s3://bucket-name





Using Amazon SNS with the AWS CLI - Part 7

You can access the features of Amazon Simple Notification Service (Amazon SNS) using the AWS Command Line Interface (AWS CLI). To list the AWS CLI commands for Amazon SNS, use the following command.
$ aws sns help
Before you run any commands, set your default credentials. For more information, see Configuring the AWS CLI.

Create a Topic

To create a topic, use the create-topic command and specify the name to assign to the topic.
$ aws sns create-topic --name my-topic
{
    "TopicArn": "arn:aws:sns:ap-south-1:123456789012:my-topic"
}
Make a note of the response's TopicArn, which you use later to publish a message.

Subscribe to a Topic

To subscribe to a topic, use the subscribe command.
The following example specifies the email protocol and an email address for the notification-endpoint.
$ aws sns subscribe --topic-arn arn:aws:sns:us-west-2:123456789012:my-topic --protocol email --notification-endpoint sujeet@example.com
{
    "SubscriptionArn": "pending confirmation"
}
AWS immediately sends a confirmation message by email to the address you specified in the subscribe command. The email message has the following text.
You have chosen to subscribe to the topic:
arn:aws:sns:us-west-2:123456789012:my-topic
To confirm this subscription, click or visit the following link (If this was in error no action is necessary):
Confirm subscription
After the recipient clicks the Confirm subscription link, the recipient's browser displays a notification message with information similar to the following.
Subscription confirmed!
You have subscribed saanvi@example.com to the topic:my-topic.

Your subscription's id is:
arn:aws:sns:us-west-2:123456789012:my-topic:1328f057-de93-4c15-512e-8bb22EXAMPLE

If it was not your intention to subscribe, click here to unsubscribe.

Publish to a Topic

To send a message to all subscribers of a topic, use the publish command.
The following example sends the message "Hello World!" to all subscribers of the specified topic.
$ aws sns publish --topic-arn arn:aws:sns:ap-south-1:123456789012:my-topic --message "Hello World!"
{
    "MessageId": "08ac5412-d867-5372-85f3-02de50785f63"

}
In this example, AWS sends an email message with the text "Hello World!" to saanvi@example.com.

Unsubscribe from a Topic

To unsubscribe from a topic and stop receiving messages published to that topic, use the unsubscribe command and specify the ARN of the topic you want to unsubscribe from.
$ aws sns unsubscribe --subscription-arn arn:aws:sns:us-west-2:123456789012:my-topic:1328f057-de93-4c15-512e-8bb22EXAMPLE
To verify that you successfully unsubscribed, use the list-subscriptions command to confirm that the ARN no longer appears in the list.
$ aws sns list-subscriptions
{
    "Subscriptions": [
        {
            "SubscriptionArn": "arn:aws:sns:ap-south-1:123456789012:sns-t-sqs:a3f3e8b5-d82c-44f1-8321-d671e1d00058",
            "Owner": "123456789012",
            "Protocol": "sqs",
            "Endpoint": "arn:aws:sqs:ap-south-1:123456789012:sqs-t-sns",
            "TopicArn": "arn:aws:sns:ap-south-1:123456789012:sns-t-sqs"
        }
    ]
}

Delete a Topic

To delete a topic, run the delete-topic command.
$ aws sns delete-topic --topic-arn arn:aws:sns:us-west-2:123456789012:my-topic
To verify that AWS successfully deleted the topic, use the list-topics command to confirm that the topic no longer appears in the list.
$ aws sns list-topics
{
    "Topics": [
        {
            "TopicArn": "arn:aws:sns:ap-south-1:123456789012:dynamodb"
        },
        {
            "TopicArn": "arn:aws:sns:ap-south-1:123456789012:my-topic"
        }
    ]
}

Amazon Elastic Container Service (ECS) - Part 2


Using Amazon DynamoDB with the AWS CLI - Part 6

To list the AWS CLI commands for DynamoDB, use the following command.
$ aws dynamodb help
Before you run any commands, set your default credentials. For more information, see Configuring the AWS CLI.
For example, the following command creates a table named MusicCollection.
$ aws dynamodb create-table \ --table-name MusicCollection \ --attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \ --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \ --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
{
  "TableDescription": {
    "AttributeDefinitions": [
      {
        "AttributeName": "Artist",
        "AttributeType": "S"
      },
      {
        "AttributeName": "SongTitle",
        "AttributeType": "S"
      }
    ],
    "TableName": "MusicCollection",
    "KeySchema": [
      {
        "AttributeName": "Artist",
        "KeyType": "HASH"
      },
      {
        "AttributeName": "SongTitle",
        "KeyType": "RANGE"
      }
    ],
    "TableStatus": "CREATING",
    "CreationDateTime": 1582461871.325,
    "ProvisionedThroughput": {
      "NumberOfDecreasesToday": 0,
      "ReadCapacityUnits": 1,
      "WriteCapacityUnits": 1
    },
    "TableSizeBytes": 0,
    "ItemCount": 0,
    "TableArn": "arn:aws:dynamodb:ap-south-1:809160705184:table/MusicCollection",
    "TableId": "00c2767a-1337-4f6d-ae81-87792185da75"
  }
}

You can add new lines to the table with commands similar to those shown in the following example. These examples use a combination of shorthand syntax and JSON.

$ aws dynamodb put-item \ --table-name MusicCollection \ --item '{ "Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Call Me Today"} , "AlbumTitle": {"S": "Somewhat Famous"} }' \ --return-consumed-capacity TOTAL { "ConsumedCapacity": { "CapacityUnits": 1.0, "TableName": "MusicCollection" } } $ aws dynamodb put-item \ --table-name MusicCollection \ --item '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"} , "AlbumTitle": {"S": "Songs About Life"} }' \ --return-consumed-capacity TOTAL
{
  "ConsumedCapacity": {
    "CapacityUnits": 1.0,
    "TableName": "MusicCollection"
  }

}
You can use that file to issue a query request using the AWS CLI.
$ aws dynamodb query --table-name MusicCollection \ --key-condition-expression "Artist = :v1 AND SongTitle = :v2" \ --expression-attribute-values file://expression-attributes.json
{
  "Count": 1,
  "Items": [
    {
      "AlbumTitle": {
        "S": "Somewhat Famous"
      },
      "SongTitle": {
        "S": "Call Me Today"
      },
      "Artist": {
        "S": "No One You Know"
      }
    }
  ],
  "ScannedCount": 1,
  "ConsumedCapacity": null

}

For example, the following command delete a table named MusicCollection.

$ aws dynamodb delete-table --table-name MusicCollection
{ "TableDescription": { "TableName": "MusicCollection", "TableStatus": "DELETING", "ProvisionedThroughput": { "NumberOfDecreasesToday": 0, "ReadCapacityUnits": 1, "WriteCapacityUnits": 1 }, "TableSizeBytes": 0, "ItemCount": 0, "TableArn": "arn:aws:dynamodb:ap-south-1:809160705184:table/MusicCollection", "TableId": "00c2767a-1337-4f6d-ae81-87792185da75" } }


For example, the following command list a table named.
$ aws dynamodb list-tables { "TableNames": [ "MusicsCollection", "VideosCollection", "SongsCollection", "DocumentCollection" ] }