# Perform Foundational Infrastructure Tasks in Google Cloud
**Cloud Storage: Qwik Start - Cloud Console**
:::success
**Insight**
1. Create a bucket
2. Upload an object into the bucket
3. Share a bucket publicly
4. Create folders
5. Delete a folder
:::
> Note: If you are prompted with Public access will be prevented, uncheck Enforce public access prevention on this bucket and click Confirm.
* Every bucket must have a unique name across the entire Cloud Storage namespace. True
* Object names must be unique only within a given bucket. True
---
**Cloud Storage: Qwik Start - CLI/SDK**
:::success
**Insight**
1. Create a bucket
2. Upload an object into the bucket
3. Download an object from your bucket
4. Copy an object to a folder in the bucket
5. List contents of a bucket or folder
6. List details for an object
7. Make your object publicly accessible
8. Remove public access
:::
---
**Cloud IAM: Qwik Start**
:::success
**Insight**
1. The IAM console and project level roles
2. The IAM console and project level roles
3. Explore editor roles
4. Prepare a resource for access testing
5. Remove project access
6. Add Storage permissions
7. Verify access
:::
---
**Cloud Monitoring: Qwik Start**
:::success
**Insight**
1. Create a Compute Engine instance
2. Add Apache2 HTTP Server to your instance
3. Create an uptime check
4. Create an alerting policy
5. Create a dashboard and chart
6. View your logs
7. Check the uptime check results and triggered alerts
:::
---
**Cloud Functions: Qwik Start - Console**
:::success
**Insight**
1. Create a function
2. Deploy the function
3. Test the function
4. View logs
:::
* Cloud Functions is a serverless execution environment for event driven services on Google Cloud. True
* Which type of trigger is used while creating Cloud Function in the lab? HTTP
---
**Cloud Functions: Qwik Start - Command Line**
:::success
**Insight**
1. Create a function
2. Create a cloud storage bucket
3. Deploy your function
4. Test the function
5. View logs
:::
* Serverless lets you write and deploy code without the hassle of managing the underlying infrastructure. True
---
**Google Cloud Pub/Sub: Qwik Start - Console**
:::success
**Insight**
1. Setting up Pub/Sub
2. Add a subscription
3. Test your understanding
4. Publish a message to the topic
5. View the message
:::
* A publisher application creates and sends messages to a "topic". Subscriber applications create a "subscription" to a topic to receive messages from it.
* Cloud Pub/Sub is an asynchronous messaging service designed to be highly reliable and scalable. True
---
**Google Cloud Pub/Sub: Qwik Start - Command Line**
:::success
**Insight**
1. Pub/Sub topics
2. Pub/Sub subscriptions
3. Pub/Sub publishing and pulling a single message
4. Pub/Sub pulling all messages from subscriptions
:::
* To receive messages published to a topic, you must create a subscription to that topic. True
---
**Google Cloud Pub/Sub: Qwik Start - Python**
:::success
**Insight**
1. Create a virtual environment
2. Install the client library
3. Pub/Sub - the Basics
4. Create a topic
5. Create a subscription
6. Publish messages
7. View messages
:::
* Google Cloud Pub/Sub service allows applications to exchange messages reliably, quickly, and asynchronously. True
* A topic is a shared string that allows applications to connect with one another.
---
**Perform Foundational Infrastructure Tasks in Google Cloud: Challenge Lab**
<!-- [Challenge Lab](https://youtu.be/XBQ1J18EOgI?feature=shared) -->
> Detailed Tutorial of Task — 1
1. Navigation menu > Cloud Storage > Browser > Create Bucket
2. Name your bucket > Enter GCP Project ID > Continue, ex: `qwiklabs-gcp-01-941843f49802-bucket`
3. Choose where to store your data > Region: ex: `us-east4` > Continue
4. Use default for the remaining
5. Create
> Detailed Tutorial of Task — 2
1. Navigation menu > Pub/Sub > Topics
2. Create Topic > Name: ex: `topic-memories-372` > Create Topic
> Detailed Tutorial of Task — 3
1. Navigation menu > Cloud Functions > Create Function
2. Use the following config: Name: memories-thumbnail-maker Region: us-west1
3. ==**Use default for the remaining**==
4. Set the **Entry point** to memories-thumbnail-maker
5. Add the following code to the `index.js`
```javascript=
const functions = require('@google-cloud/functions-framework');
const crc32 = require("fast-crc32c");
const { Storage } = require('@google-cloud/storage');
const gcs = new Storage();
const { PubSub } = require('@google-cloud/pubsub');
const imagemagick = require("imagemagick-stream");
functions.cloudEvent('memories-thumbnail-maker', cloudEvent => {
const event = cloudEvent.data;
console.log(`Event: ${event}`);
console.log(`Hello ${event.bucket}`);
const fileName = event.name;
const bucketName = event.bucket;
const size = "64x64"
const bucket = gcs.bucket(bucketName);
const topicName = "topic-memories-761";
const pubsub = new PubSub();
if ( fileName.search("64x64_thumbnail") == -1 ){
// doesn't have a thumbnail, get the filename extension
var filename_split = fileName.split('.');
var filename_ext = filename_split[filename_split.length - 1];
var filename_without_ext = fileName.substring(0, fileName.length - filename_ext.length );
if (filename_ext.toLowerCase() == 'png' || filename_ext.toLowerCase() == 'jpg'){
// only support png and jpg at this point
console.log(`Processing Original: gs://${bucketName}/${fileName}`);
const gcsObject = bucket.file(fileName);
let newFilename = filename_without_ext + size + '_thumbnail.' + filename_ext;
let gcsNewObject = bucket.file(newFilename);
let srcStream = gcsObject.createReadStream();
let dstStream = gcsNewObject.createWriteStream();
let resize = imagemagick().resize(size).quality(90);
srcStream.pipe(resize).pipe(dstStream);
return new Promise((resolve, reject) => {
dstStream
.on("error", (err) => {
console.log(`Error: ${err}`);
reject(err);
})
.on("finish", () => {
console.log(`Success: ${fileName} → ${newFilename}`);
// set the content-type
gcsNewObject.setMetadata(
{
contentType: 'image/'+ filename_ext.toLowerCase()
}, function(err, apiResponse) {});
pubsub
.topic(topicName)
.publisher()
.publish(Buffer.from(newFilename))
.then(messageId => {
console.log(`Message ${messageId} published.`);
})
.catch(err => {
console.error('ERROR:', err);
});
});
});
}
else {
console.log(`gs://${bucketName}/${fileName} is not an image I can handle`);
}
}
else {
console.log(`gs://${bucketName}/${fileName} already has a thumbnail`);
}
});
```
5. Add the following code to the `package.json`
```json
{
"name": "thumbnails",
"version": "1.0.0",
"description": "Create Thumbnail of uploaded image",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"@google-cloud/functions-framework": "^3.0.0",
"@google-cloud/pubsub": "^2.0.0",
"@google-cloud/storage": "^5.0.0",
"fast-crc32c": "1.0.4",
"imagemagick-stream": "4.1.1"
},
"devDependencies": {},
"engines": {
"node": ">=4.3.2"
}
}
```
> Detailed Tutorial of Task — 4
1. Navigation menu > IAM & Admin > IAM
1. Search for the "Username 2" > Edit > Delete Role