How Do You Find the Working Directory in an Azure DevOps Release Pipeline?

Problem scenario
A Terraform task is failing in an Azure DevOps release pipeline. You cannot see a variable setting for the working directory. How do you determine the working directory?

Solution
Go to Edit your release pipeline. Go to "View YAML" in the upper right hand corner. Search for "working". You should see it (e.g., as workingDirectory).

The working directory key probably has a value that is a variable (e.g., $foobar). Find $foobar in the relevant Task in the Azure DevOps Release pipeline (and remember that Terraform tasks have a Terraform logo near them.). Consider changing the $foobar variable (e.g., use an option to drill down). The variable key may be called (or invoked) in the "Configuration Directory" in the Azure DevOps pipeline task. The $foobar variable value may need to be changed (but these directions are just for identifying its value). You may need to look at the individual Tasks of the release or the Variables tab of the pipeline.


This solution was partially adapted from two independent articles (external blog posting here and another one here) and this medium.com article.

What Is The Disambiguation of The Word “heap” in I.T.?

Problem scenario
You have read about heaps in computer programming and in operating systems. What do the different definitions of "heap" mean in I.T.?

Overview
Merriam-Webster's Dictionary (11th Edition, on page 574) defines a heap as "a collection of things thrown one on another" or as a "pile." The same word can have completely different meanings in English; a trash heap, a heap in computer programming, a heap in the context of operating systems, and a heap in databases are a few types of "heaps". Their definitions are completely independent of one another.

Possible Solution #1 (for computer programming)
A heap is an abstract data structure that is a binary tree with the maximum value as the root. To learn more see https://www.educative.io/edpresso/what-is-a-heap

Cracking the Coding Interview says a heap is a complete binary tree that has nodes that are ordered (page 103). If a tree (a data structure) has the heap property it is said to be a heap.

Possible Solution #2 (for operating systems)
An allocation of memory. To learn more, see https://www.geeksforgeeks.org/stack-vs-heap-memory-allocation/ The heap is a segment of a process's memory; it is "an area from which programs can dynamically allocate extra memory." (The source of this quote is page 31 of The Linux Programming Interface.)

To learn more about the disambiguation, see this link: https://techterms.com/definition/heap

Possible Solution #3 (for relational/SQL databases)
"A heap is a table without a clustered index." (Taken from Microsoft.)

"A heap-table stores the rows in an unordered fashion." (Taken from use-the-index-luke.com.)

AWS Quiz

1. Which is one of the five pillars of a well-architected AWS framework?

a. Archived versions (of IaC)
b. Disaster Recovery
c. Monitoring
d. Performance Efficiency
e. None of the above

2. Signature version 4 is which of the following?

a. A certificate file from Amazon Web Security.
b. An SSL public key for AWS.
c. An SSL private key for AWS.
d. It is the AWS HTTP authentication method that combines the access key ID and secret access key.

3. For dependencies of an AWS Lambda layer, how many layers are allowed?

a. 1
b. 2
c. 5
d. Unlimited

4. How many parameters can be passed to a CloudFormation template?

a. 3
b. 30
c. 60
d. 100
e. Unlimited

5. What is Fn in CloudFormation templates?

_____________________________

6. What percentage of professional hours of a migration project for an application into AWS is normally spent on testing?

a. 2%
b. 15%
c. 30%
d. 45%

7. Which of the six Rs (for an AWS Migration) is described as "drop-and-shop"?

a. rehost
b. replatform
c. repurchase
d. refactor/re-architect
e. retain
f. retire

8. Which of the six Rs (for an AWS Migration) is described as "lift-and-shift"?

a. rehost
b. replatform
c. repurchase
d. refactor/re-architect
e. retain
f. retire

9. Which three of the following are not part of the five phases of a migration that AWS recommends (per their five-phase migration process diagram)?

a. Migration Preparation & Business Planning
b. Quality Assurance
c. Portfolio Discovery & Planning
d. Administrate
e. Migration & Validation
f. Quality of service testing
g. Application Design
e. Operate

10. Which of the six Rs (for an AWS Migration) is described as "lift-tinker-and-shift"?

a. rehost
b. replatform
c. repurchase
d. refactor/re-architect
e. retain
f. retire

11. Is RDS an example of a serverless AWS offering?

Yes
No

12. Is Lambda an example of a serverless AWS offering?

Yes
No

13. An Amazon VPC can include which of the following?

a. VPNs
b. routing rules
c. subnets
d. NACLs (network ACLs)
e. All of the above
f. None of the above

14. The WorkSpaces "Running Mode" dramatically affects which of the following?

a. The processing performance (i.e., CPU) of the WorkSpace itself.
b. The memory performance (i.e., RAM) of the WorkSpace itself.
c. The duration the WorkSpace will be available to you.
d. None of the above.

15. What is a Change Set in CloudFormation?
___________________________________

16. What is the difference between a template and a stack in CloudFormation?

___________________________________________

17. VPCs are referred to as what in AWS when you are configuring an EC-2 instance?

a. Clusters
b. Sections
c. Networks
d. Subnets
e. Isolation chambers

18. What is a Lambda layer?

a. A line of code in a Lambda function
b. A Lambda used by another Lambda
c. A Lambda that creates one or more VPCs
d. None of the above.

For the answers, click here.

AWS Quiz Answers

1. Which is one of the five pillars of a well-architected AWS framework?

a. Archived versions (of IaC)
b. Disaster Recovery
c. Monitoring
d. Performance Efficiency
e. None of the above

Answer: D. Source: https://aws.amazon.com/blogs/apn/the-5-pillars-of-the-aws-well-architected-framework/

2. Signature version 4 is which of the following?

a. A certificate file from Amazon Web Security.
b. An SSL public key for AWS.
c. An SSL private key for AWS.
d. It is the AWS HTTP authentication method that combines the access key ID and secret access key.

Answer: D. Source:
https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html

3. For dependencies of an AWS Lambda layer, how many layers are allowed?

a. 1
b. 2
c. 5
d. Unlimited

Answer: C. Source https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html

4. How many parameters can be passed to a CloudFormation template?

a. 3
b. 30
c. 60
d. 100
e. Unlimited

Answer: C. Source: https://aws.amazon.com/cloudformation/faqs/

5. What is Fn in CloudFormation templates?

Answer: Fn is the syntax to refer to different intrinsic functions. These functions do various things such as return values during CloudFormation operations. There is a cfn-init command that is part of AWS CloudFormation. Apparently the cfn stands for CloudFormation. To learn more, click here.

6. What percentage of professional hours of a migration project for an application into AWS is normally spent on testing?

a. 2%
b. 15%
c. 30%
d. 45%

Answer: D. Source page 7 of https://d0.awsstatic.com/whitepapers/Migration/migrating-applications-to-aws.pdf

7. Which of the six Rs (for an AWS Migration) is described as "drop-and-shop"?

a. rehost
b. replatform
c. repurchase
d. refactor/re-architect
e. retain
f. retire

Answer: C. Source: Page 13 of https://d1.awsstatic.com/Migration/migrating-to-aws-ebook.pdf

8. Which of the six Rs (for an AWS Migration) is described as "lift-and-shift"?

a. rehost
b. replatform
c. repurchase
d. refactor/re-architect
e. retain
f. retire

Answer: A. Source: Page 13 of https://d1.awsstatic.com/Migration/migrating-to-aws-ebook.pdf

9. Which three of the following are not part of the five phases of a migration that AWS recommends (per their five-phase migration process diagram)?

a. Migration Preparation & Business Planning
b. Quality Assurance
c. Portfolio Discovery & Planning
d. Administrate
e. Migration & Validation
f. Quality of service testing
g. Application Design
e. Operate

Answer: B, D, F. Source page 8 of https://d1.awsstatic.com/Migration/migrating-to-aws-ebook.pdf

10. Which of the six Rs (for an AWS Migration) is described as "lift-tinker-and-shift"?

a. rehost
b. replatform
c. repurchase
d. refactor/re-architect
e. retain
f. retire

Answer: B. Source: Page 13 of https://d1.awsstatic.com/Migration/migrating-to-aws-ebook.pdf

11. Is RDS an example of a serverless AWS offering?

Yes
No

Answer: No. See https://acloud.guru/forums/aws-csa-2019/discussion/-LtPWTfYtKgh4qX97LlO/RDS%20is%20NOT%20Serverless

12. Is Lambda an example of a serverless AWS offering?

Yes
No

Answer: Yes. See https://aws.amazon.com/lambda/

13. An Amazon VPC can include which of the following?

a. VPNs
b. routing rules
c. subnets
d. NACLs (network ACLs)
e. All of the above
f. None of the above

Answer: E. Source: Page 94 of Terraform Up & Running.

14. The WorkSpaces "Running Mode" dramatically affects which of the following?

a. The processing performance (i.e., CPU) of the WorkSpace itself.
b. The memory performance (i.e., RAM) of the WorkSpace itself.
c. The duration the WorkSpace will be available to you.
d. None of the above.

Answer: C. Source: https://aws.amazon.com/workspaces/pricing/
You must buy an entire month of the WorkSpace if you configure the WorkSpace's "Running Mode" as an "AlwaysOn". Early cancellations will not allow you to save money if you use it for even one minute.

15. What is a Change Set in CloudFormation?
___________________________________

Answer: It is the difference between a deployed stack and a new desired state for the stack. Change sets allow you to preview the changes to the stack. They can be a dry run or something to be executed.
Source: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets.html

16. What is the difference between a template and a stack in CloudFormation?

___________________________________________

Answer: A stack is a deployed set of IaaS and/or PaaS components in AWS that usually is configured to interact with itself in a useful way. A template is a JSON or YAML file used to deploy a stack.
Source: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-whatis-concepts.html

17. VPCs are referred to as what in AWS when you are configuring an EC-2 instance?

a. Clusters
b. Sections
c. Networks
d. Subnets
e. Isolation chambers

Answer: C. When you configure a new EC-2 instance, the Step 3's title is "Configure Instance Details". There is a "Network" drop down menu next to a link "Create new VPC."

18. What is a Lambda layer?

a. A line of code in a Lambda function
b. A Lambda used by another Lambda
c. A Lambda that creates one or more VPCs
d. None of the above.

Answer: D. Source:
https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html

How Do You Boot to One of Two Hard Drives?

Problem scenario
You have two hard drives in your laptop. You want to be able to boot to one or the other. The BIOS options are confusing. What do you do?

Possible Solution (directions primarily for HP laptops)

  1. Power off the laptop.
  2. Turn on the laptop and press "Esc" for the Start Menu.
  3. Go to F10 BIOS Setup.
  4. Go to the "Security" tab.
  5. Go to the Boot Options -> Boot Mode. Choose either Legacy or "UEFI Native (without CSM)". If you alternate between these you may be able to boot to the hard drive of your choice.
  6. In the Advanced tab, go to Multiboot Express Popup Delay (sec) -> Choose 5 sec (or longer).
  7. Save all the changes. Each time you switch between them, you may have to go into this Startup Menu and the Security Tab and perform step #5 again. We know this is not an optimal solution, but it may or may not help you.

How Do You Create a File on a Server with Terraform?

Problem scenario
You are trying to get user data to create a file on a server in Terraform. It is in a directory that requires sudo privileges. You use the "sudo" command in the Bash script. The Bash script executes except a file is never transferred. How do you get Terraform to copy a file to a new server?

Solution
Use the Terraform-supported cloud_config option instead of having a Bash script transfer the file.

Here is the content of the file:

provider "aws" {
  access_key = "AKIAabcd1234"
  secret_key = "secret/foobar"
  region     = "us-west-1"
}

resource "aws_instance" "example" {
  ami           = "ami-1234"
  instance_type = "t2.large"
  key_name      = "good_key"
  user_data     = local.cloud_config_config
}

locals {
  cloud_config_config = <<-END
    #cloud-config
    ${jsonencode({
      write_files = [
        {
          path        = "/etc/yum.repos.d/fun.repo"
          permissions = "0644"
          owner       = "root:root"
          content     = file("sourcefile.repo")
        },
      ]
    })}
  END
}

How Do You Do a regex Operation in Python without Importing a Module?

Problem scenario
You need a pattern matching function in a Python program, but you cannot use "import re". What should you do?

Possible Solution #1
Use the index() function.

Here is an example:

foobar = "abcdefghijklmnopqrstuvwxyz"
print(foobar.index('jk'))

Possible Solution #2
Use the .starswith() function.

foobar = "abcdefghijklmnopqrstuvwxyz"
print(foobar.startswith('abc'))

Possible Solution #3
Use the find() function.

foobar = "abcdefghijklmnopqrstuvwxyz"
print(foobar.find('z'))