100% found this document useful (2 votes)
29 views

Instant Access to AWS Automation Cookbook Continuous Integration and Continuous Deployment using AWS services 1st Edition Nikit Swaraj ebook Full Chapters

Deployment

Uploaded by

ayshasandry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
29 views

Instant Access to AWS Automation Cookbook Continuous Integration and Continuous Deployment using AWS services 1st Edition Nikit Swaraj ebook Full Chapters

Deployment

Uploaded by

ayshasandry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

AWS Automation Cookbook Continuous Integration and


Continuous Deployment using AWS services 1st
Edition Nikit Swaraj

https://textbookfull.com/product/aws-automation-cookbook-
continuous-integration-and-continuous-deployment-using-aws-
services-1st-edition-nikit-swaraj/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Hands-on Azure Pipelines: Understanding Continuous


Integration and Deployment in Azure DevOps 1st Edition
Chaminda Chandrasekara
https://textbookfull.com/product/hands-on-azure-pipelines-
understanding-continuous-integration-and-deployment-in-azure-
devops-1st-edition-chaminda-chandrasekara/
textboxfull.com

Android Continuous Integration: Build-Deploy-Test


Automation for Android Mobile Apps Pradeep Macharla

https://textbookfull.com/product/android-continuous-integration-build-
deploy-test-automation-for-android-mobile-apps-pradeep-macharla/

textboxfull.com

Data Science on AWS Implementing End to End Continuous AI


and Machine Learning Pipelines Early Edition Chris Fregly

https://textbookfull.com/product/data-science-on-aws-implementing-end-
to-end-continuous-ai-and-machine-learning-pipelines-early-edition-
chris-fregly/
textboxfull.com

Xamarin Continuous Integration and Delivery: Team


Services, Test Cloud, and HockeyApp 1st Edition Gerald
Versluis (Auth.)
https://textbookfull.com/product/xamarin-continuous-integration-and-
delivery-team-services-test-cloud-and-hockeyapp-1st-edition-gerald-
versluis-auth/
textboxfull.com
Learning AWS Design build and deploy responsive
applications using AWS Cloud components Aurobindo Sarkar

https://textbookfull.com/product/learning-aws-design-build-and-deploy-
responsive-applications-using-aws-cloud-components-aurobindo-sarkar/

textboxfull.com

Practical Machine Learning with AWS Process Build Deploy


and Productionize Your Models Using AWS 1st Edition
Himanshu Singh
https://textbookfull.com/product/practical-machine-learning-with-aws-
process-build-deploy-and-productionize-your-models-using-aws-1st-
edition-himanshu-singh/
textboxfull.com

Practical Machine Learning with AWS : Process, Build,


Deploy, and Productionize Your Models Using AWS Himanshu
Singh
https://textbookfull.com/product/practical-machine-learning-with-aws-
process-build-deploy-and-productionize-your-models-using-aws-himanshu-
singh/
textboxfull.com

Python Continuous Integration and Delivery: A Concise


Guide with Examples Lenz

https://textbookfull.com/product/python-continuous-integration-and-
delivery-a-concise-guide-with-examples-lenz/

textboxfull.com

GitOps and Kubernetes: Continuous Deployment with Argo CD,


Jenkins X, and Flux 1st Edition Billy Yuen

https://textbookfull.com/product/gitops-and-kubernetes-continuous-
deployment-with-argo-cd-jenkins-x-and-flux-1st-edition-billy-yuen/

textboxfull.com
AWS Automation Cookbook

Continuous Integration and Continuous Deployment using


AWS services

Nikit Swaraj

BIRMINGHAM - MUMBAI
AWS Automation Cookbook
Copyright © 2017 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its
dealers and distributors will be held liable for any damages caused or alleged to be caused
directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: November 2017

Production reference: 1221117


Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78839-492-5

www.packtpub.com
Credits
Author Copy Editor
Nikit Swaraj Charlotte Carneiro

Reviewer Project Coordinator


Gajanan Chandgadkar Virginia Dias

Commissioning Editor Proofreader


Vijin Boricha Safis Editing

Acquisition Editor Indexer


Meeta Rajani Aishwarya Gangawane

Content Development Editor Graphics


Sharon Raj Kirk D'Penha

Technical Editor Production Coordinator


Mohit Hassija Shantanu Zagade
About the Author
Nikit Swaraj is an experienced professional DevOps/Solutions Architect. He understands
the melding of development and operations to deliver efficient code. He has expertise in
designing, developing, and delivering enterprise-wide solutions that meet business
requirements and enhance operational efficiency. As an AWS solutions architect, he has
vast experience in designing end-to-end IT solutions and leading and managing complete
life cycle projects within optimal time and budget. He also contributes to Kubernetes (open
source).

He has been associated with enterprises such as Red Hat and APNs (AWS Partner
Network). He is a certified Red Hat/OpenStack architect, as well as being an AWS solutions
architect. He also writes blogs on CI/CD with AWS Developer Tools, Docker, Kubernetes,
Serverless, and much more.
Acknowledgments
I would like to express my gratitude to Packt Publishing who have given me the
tremendous opportunity to write this book. I would like to thank Meeta Rajani (senior
acquisition editor, Packt), who encouraged and enabled me to write this book.

I would like to show my appreciation and thanks to Sharon Raj, Mohit Hassija, and the
team at Packt, who saw me through this book, provided support, talked things over, read,
offered comments, reviewed, allowed me to quote their remarks, and assisted in the editing,
proofreading, and design. This book would not have been completed without your help.

I would also like to thank some of my mentors, with whom I learned and implemented
about AWS and DevOps, among which the first name is Tarun Prakash (senior DevOps
engineer, MediaIQ Digital) who helped and guided me when I entered the world of
DevOps and AWS. I would like to thank Rahul Natarajan (lead cloud architect and
consultant, Accenture) who has given me guidance and enabled me to use Developer Tools
and related services of AWS and DevOps tools and technologies. I would also like to thank
Santosh Panicker (senior technical account manager, Amazon Web Services), under whom I
have worked and learned a lot about infrastructure and client requirements. He made me
understand which services can be used in the best way. My certifications are a different
scenario, but this person had molded me into an actual solutions architect.

I would also like to thank my family and best friends Vijeta and Tanushree for encouraging
me and providing me with the emotional support to complete this book.
About the Reviewer
Gajanan Chandgadkar has more than 12 years of IT experience. He has spent more than 6
years in the USA helping large enterprises in architecting, migrating, and deploying
applications in AWS. He’s been running production workloads on AWS for over 6 years. He
is an AWS certified solutions architect professional and a certified DevOps professional
with more than 7 certifications in trending technologies. Gajanan is also a technology
enthusiast who has extended interest and experiences in different topics such as application
development, container technology, and Continuous Delivery.

Currently, he is working with Happiest Minds Technologies as Associate DevOps Architect


and has worked with Wipro Technologies Corporation in the past.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com. Did
you know that Packt offers eBook versions of every book published, with PDF and ePub
files available? You can upgrade to the eBook version at www.PacktPub.com and as a print
book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
[email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters and receive exclusive discounts and offers on Packt books and
eBooks.

https:/​/​www.​packtpub.​com/​mapt

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt
books and video courses, as well as industry-leading tools to help you plan your personal
development and advance your career.

Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial
process. To help us improve, please leave us an honest review on this book's Amazon page
at https:/​/​www.​amazon.​com/​dp/​1788394925.

If you'd like to join our team of regular reviewers, you can email us at
[email protected]. We award our regular reviewers with free eBooks and
videos in exchange for their valuable feedback. Help us be relentless in improving our
products!
Table of Contents
Preface 1
Chapter 1: Using AWS CodeCommit 7
Introduction 7
Introducing VCS and Git 7
What is VCS? 8
Why VCS ? 8
Types of VCS 8
What is Git? 9
Why Git over other VCSs? 9
Features of Git 11
How to do it... 12
Installation of Git and its implementation using GitHub 12
Introducing AWS CodeCommit - Amazon managed SaaS Git 16
How to do it... 18
Getting started with CodeCommit for HTTP users 19
How to do it... 19
Setting up CodeCommit for SSH users using AWS CLI 27
Getting ready 27
How to do it... 28
Applying security and restrictions 31
Getting ready 32
How to do it... 32
Migrating a Git repository to AWS CodeCommit 36
How to do it... 36
Chapter 2: Building an Application using CodeBuild 40
Introduction 40
Introducing AWS CodeBuild 42
How to do it... 43
How it works... 43
Pricing 44
Building a Java application using Maven 45
Getting ready 45
Install Java and verify 45
Install Apache Maven and verify 45
How to do it... 46
Table of Contents

Building a NodeJS application using yarn 50


Getting ready 51
Install NodeJS and verify 51
Install Yarn and verify 51
How to do it... 51
Installing dependencies 53
How it works... 55
Building a Maven application using AWS CodeBuild console 55
Getting ready 55
How it works... 56
Building a sample NodeJS application using AWS CodeBuild via
Buildspec.yml 65
Buildspec.yml 66
Syntax 66
Getting ready 68
How to do it... 69
Chapter 3: Deploying Application using CodeDeploy & CodePipeline 77
Introduction 77
The Deployment strategy in AWS CodeDeploy 81
In-place deployment 81
Blue-green deployment 82
How to do it... 82
Writing an application-specific file 84
How to do it... 84
Deploying a static application in an EC2 instance from the S3 Bucket
using AWS CodeDeploy 87
Getting ready 87
How to do it... 88
How it works... 103
Introducing AWS CodePipeline and its working 103
How to do it... 103
How it works... 105
Continuous Deployment of static application to AWS S3 using AWS
CodePipeline 105
How to do it... 106
Chapter 4: Building Scalable and Fault-Tolerant CI/CD Pipeline 119
Introduction 119
Benefits of using the CI/CD pipeline 120
How to achieve the benefits? 120

[ ii ]
Table of Contents

The scenario 120


The challenges 121
CI/CD pipeline workflow 121
Getting ready 122
How to do it... 122
Setting up AWS CodeCommit 125
Getting ready 126
How to do it... 126
Creating the S3 bucket and enabling versioning 129
Getting ready 129
How to do it... 129
Creating the launch configuration and Auto Scaling group 131
Getting ready 131
How to do it... 131
Creating AWS CodeDeploy application using the Auto Scaling group 138
Getting ready 139
How to do it... 139
Setting up the Jenkins Server and installing the required plugins 140
Getting ready 141
How to do it... 141
Integrating Jenkins with all of the AWS developers tools 143
Getting ready 143
How to do it... 144
Chapter 5: Understanding Microservices and ECS 159
Introduction 159
Understanding microservices and their deployment 160
Designing microservices 161
Deployment of microservices 162
Playing around with Docker containers 162
Containers 162
Docker 163
Images 163
Registry 163
Containers 163
Getting ready 164
Installation of Docker engine 164
Run Docker as a non-root user 165
How to do it... 165
Running a container 166
Starting the stopped container 167
Assigning a Name to a container 168

[ iii ]
Table of Contents

Creating daemonized containers 168


Exposing ports of a container 169
Managing persistent storage with Docker 170
Adding a data volume 170
Getting details of a container 170
Containerize your application using Dockerfile 171
Push the image to Dockerhub 173
Setting up AWS ECR and pushing an image into it 174
Getting ready 174
How to do it... 175
To authenticate Docker client with ECR 177
Tagging your Docker Image with the repository details 178
Pushing the image to ECR 179
Understanding ECS and writing task definitions and services 180
Getting ready 184
How to do it... 184
Verifying containers inside the Container instance 195
Chapter 6: Continuous Deployment to ECS Using Developer Tools and
CloudFormation 198
Introduction 198
Understanding the architecture and workflow 199
How to do it... 199
How it works... 201
Setting up the infrastructure to host the application 202
Getting ready 203
How to do it... 203
Creating an ECS cluster 203
Creating a Load Balancer (Classic ELB) 206
Register Auto Scaling with Load Balancer 209
Creating an Amazon ECR 210
Setting Up CodeCommit for our application source 211
Getting ready 211
How to do it... 211
Creating a CodeBuild project for the build stage 213
Getting ready 214
How to do it... 214
Understanding the inside content of helper files (BuildSpec.yml,
Dockerfile, and CF template) 216
How to do it... 216
Creating a CodePipeline using CodeCommit, CodeBuild, and
CloudFormation 221

[ iv ]
Table of Contents

Getting ready 221


How to do it... 221
Chapter 7: IaC Using CloudFormation and Ansible 229
Introduction 229
AWS CloudFormation and writing the CloudFormation template 231
Terms and concepts related to AWS CloudFormation 232
For YAML 232
For JSON 233
How to do it... 234
Writing a CF template 234
Defining parameters 236
Using parameters 237
Creating stack using the CF template 241
Creating a production-ready web application infrastructure using
CloudFormation 245
Getting ready 246
How to do it... 247
Automation with Ansible 250
Workflow 252
Installation 252
How to do it... 252
File structure and syntax 253
Deploying a web server using Ansible 254
Creating an AWS infrastructure using the Ansible EC2 dynamic
inventory 255
Getting ready 256
How to do it... 257
Chapter 8: Automating AWS Resource Control Using AWS Lambda 260
Introduction 260
Creating an AMIs of the EC2 instance using AWS lambda and
CloudWatch 261
Getting ready 261
How to do it... 262
Sending notifications through SNS using Config and Lambda 271
Getting ready 271
How to do it... 272
Configuring the AWS Config service for AWS resources 278
Creating a Lambda function 280
Creating a trigger 282

[v]
Table of Contents

Streaming and visualizing AWS CloudTrail logs in real time using


Lambda with Kibana 285
Workflow 286
Getting ready 287
How to do it... 287
Enabling CloudTrail logs 287
Configuring CloudWatch 289
Creating Elasticsearch 290
Enabling the streaming of CloudWatch logs in Elasticsearch 295
Configuring Kibana to visualize your data 299
Chapter 9: Microservice Applications in Kubernetes Using Jenkins
Pipeline 2.0 303
Introduction 304
K8s architecture 304
Master components 305
Node components 306
Deploying multinode clusters on AWS using the Ansible playbook 306
Getting ready 307
How to do it... 308
Deploying a multinode production-ready cluster on AWS using Kops 310
Getting ready 311
How to do it... 312
Creating bucket 312
DNS configuration 312
Creating a cluster 313
Kubernetes dashboard (UI) 315
Clean up 316
Deploying a sample application on Kubernetes 317
Getting ready 317
How to do it... 317
Configuration file 320
Deployment configuration file 320
Service configuration file 321
Working with Kubernetes on AWS using AWS resources 322
Getting ready 324
How to do it... 324
Creating a persistent volume claim 324
Deployment configuration file (includes ECR image and PVC ) 326
Service configuration file (type Loadbalancer) 328
Jenkins pipeline 2.0 (Pipeline as Code) using Jenkinsfile 330
How to do it... 333
Declarative pipeline 334

[ vi ]
Table of Contents

Sections 335
Application deployment using Jenkinsfile 336
Getting ready 336
How to do it... 337
Create a pipeline in the BlueOcean 337
Clean Up 345
Creating a Pipeline using existing Jenkinsfile 346
Deploying microservices applications in Kubernetes using Jenkinsfile 347
Getting ready 348
How to do it... 349
Workflow 349
Chapter 10: Best Practices and Troubleshooting Tips 354
Best practices with AWS CodeCommit 354
Troubleshooting with CodeCommit 355
Troubleshooting with CodeBuild 357
Index 358

[ vii ]
Preface
AWS provides a set of powerful services that help companies to increase or improve rapid
build and reliable build processes to deliver products using AWS and DevOps practices.
These services help to simplify the provision and management of infrastructures, the
building of applications, and deploying application code in an environment. DevOps is
basically a combination of practices, culture, and tools that increase an organization's
productivity. It helps to increase the ability to deliver applications and services efficiently.
This helps organizations to serve their customers in a better way and to compete more
effectively in the market.

You can leverage AWS services for DevOps, meaning you can use AWS services to increase
an organization's productivity by automating CI/CD to deliver products quickly. The
Developer Tools of AWS include CodeCommit, which uses Git for VCS; CodeBuild,
which helps to build the code; CodeDeploy, which helps to deploy application code to
servers; and CodePipeline, which helps to integrate all of the previous services to create an
automated pipeline. So, this book covers how to use the AWS Developer Tools and how to
integrate them with each other. Further, this book covers enterprise-grade scenarios and
creates CI/CD pipelines for application deployment. Since this book covers the details of
how to use the core services, you can also create your CI/CD pipeline based on your use
cases.

This book also covers how to set up production-ready infrastructures using


CloudFormation and Ansible. Since many enterprises are migrating their applications to
microservices and the best enterprise-grade container orchestration tool is Kubernetes, I will
cover how you can deploy Kubernetes on AWS using KOPS, and how you can automate
application deployment in Kubernetes using Jenkins Pipeline, which is Pipeline as Code.
This book covers the automation of daily jobs and security compliance using AWS Lambda
and some other services of AWS services, such as SNS, Config, and Elasticsearch.

What this book covers


Chapter 1, Using AWS CodeCommit, covers the basic concepts of VCS. Here, you will learn
how to create a repository in GitHub and upload local files to the remote repository. Then,
you will learn CodeCommit in detail and also play with some operations, such as cloning
using SSH or HTTPS and migrating from GitHub to CodeCommit.
Preface

Chapter 2, Building an Application Using AWS CodeBuild, introduces how to build two
different applications developed in Java and NodeJS using CodeBuild. This chapter will
also show you how you can use a build specification file.

Chapter 3, Deploying an Application Using AWS CodeDeploy and AWS CodePipeline, covers the
basics of the deployment strategy used by CodeDeploy. Then, post that you will learn how
to write an application specification file that helps CodeDeploy to deploy an application to
the servers. You will also learn how CodePipeline is used to integrate the Developer Tools.

Chapter 4, Building a Highly Scalable and Fault-Tolerant CI/CD Pipeline, includes recipes
which include the steps to create a highly scalable and fault-tolerant pipeline. The recipes
include setting up CodeCommit, S3 buckets, Auto Scaling, CodeDeploy projects, and more.

Chapter 5, Understanding Microservices and AWS ECS, covers microservices and its
deployment. You will also learn to play around with Docker containers. Then, you will
learn about ECS and its components, and also how to deploy a containerized application in
ECS.

Chapter 6, Continous Deployment to AWS ECS Using CodeCommit, CodeBuild, CloudFormation,


and CodePipeline, contains recipes to build a pipeline for the continuous deployment of a
containerized application to AWS ECS using other AWS services.

Chapter 7, IaC Using CloudFormation and Ansible, contains the syntax and structure that
helps you write a CloudFormation template to spin-up AWS resources. It also includes a
CloudFormation template that will help with setting up production-ready infrastructures.
The same thing is also mentioned regarding Ansible.

Chapter 8, Automating AWS Resource Control Using AWS Lambda, contains recipes that are
related to audit compliance and automation with AWS resources, such as creating an AMI
of the EC2 instance using AWS Lambda and CloudWatch, sending notifications through
SNS using Config and Lambda, and streaming and visualizing AWS CloudTrail logs in real
time using Lambda with Kibana.

Chapter 9, Deploying Microservice Application in Kubernetes using Jenkins Pipeline 2.0, contains
recipes covering the deployment of Kubernetes on AWS using KOPS and custom Ansible
playbooks. You will also learn to use Jenkinsfile and using Jenkinsfile, deploy a
containerized application in Kubernetes.

Chapter 10, Best Practices and Troubleshooting Tips, includes some best practices with
CodeCommit and CodeBuild and also covers troubleshooting tips.

[2]
Preface

What you need for this book


The following are the basic requirements to get the most out of this book:

A Linux system (preferably CentOS/Red Hat) with a browser and a good editor
An AWS account

Who this book is for


This book targets developers and system administrators who are responsible for hosting an
application and managing instances in AWS. DevOps engineers looking at providing
continuous integration and deployment and delivery will also find this book useful. A basic
understanding of AWS, Jenkins, and some scripting knowledge will be needed.

Sections
In this book, you will find several headings that appear frequently (Getting ready, How to do
it…, How it works…, There's more…, and See also). To give clear instructions on how to
complete a recipe, we use these sections as follows:

Getting ready
This section tells you what to expect in the recipe, and describes how to set up any software
or any preliminary settings required for the recipe.

How to do it…
This section contains the steps required to follow the recipe.

How it works…
This section usually consists of a detailed explanation of what happened in the previous
section.

[3]
Preface

There's more…
This section consists of additional information about the recipe in order to make the reader
more knowledgeable about the recipe.

See also
This section provides helpful links to other useful information for the recipe.

Conventions
In this book, you will find a number of text styles that distinguish between different kinds
of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The
reason for this is we have given access to only two operations or actions: git push and git
clone."

A block of code is set as follows:


{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:GitPull",
"codecommit:GitPush"
],
"Resource": "arn:aws:codecommit:us-east-1:x60xxxxxxx39:HelloWorld"
}
]
}

Any command-line input or output is written as follows:


# git config --global user.name “awsstar”

New terms and important words are shown in bold. Words that you see on the screen, for
example, in menus or dialog boxes, appear in the text like this: "Click on Create
Policy; then we will have our own custom policy."

[4]
Preface

Warnings or important notes appear like this.

Tips and tricks appear like this.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this
book-what you liked or disliked. Reader feedback is important for us as it helps us develop
titles that you will really get the most out of. To send us general feedback, simply email
[email protected], and mention the book's title in the subject of your message. If
there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you
to get the most from your purchase.

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-
we would be grateful if you could report this to us. By doing so, you can save other readers
from frustration and help us improve subsequent versions of this book. If you find any
errata, please report them by visiting http:/​/​www.​packtpub.​com/​submit-​errata, selecting
your book, clicking on the Errata Submission Form link, and entering the details of your
errata. Once your errata are verified, your submission will be accepted and the errata will
be uploaded to our website or added to any list of existing errata under the Errata section of
that title. To view the previously submitted errata, go to https:/​/​www.​packtpub.​com/
books/​content/​support and enter the name of the book in the search field. The required
information will appear in the Errata section.

[5]
Preface

Piracy
Piracy of copyrighted material on the internet is an ongoing problem across all media. At
Packt, we take the protection of our copyright and licenses very seriously. If you come
across any illegal copies of our works in any form on the internet, please provide us with
the location address or website name immediately so that we can pursue a remedy. Please
contact us at [email protected] with a link to the suspected pirated material. We
appreciate your help in protecting our authors and our ability to bring you valuable
content.

Questions
If you have a problem with any aspect of this book, you can contact us at
[email protected], and we will do our best to address the problem.

[6]
Using AWS CodeCommit
1
The following recipes will be covered in this chapter:

Introducing VCS and Git


Introducing AWS CodeCommit - Amazon managed SAAS Git
Getting started with CodeCommit for HTTP users
Setting up CodeCommit for SSH users using AWS CLI
Applying security and restrictions
Migrating a Git repository to AWS CodeCommit

Introduction
In this chapter, we will be working with Git and will mostly play around with AWS
CodeCommit. We will set up a repository in AWS CodeCommit using the console, as well
as CLI, and enforce a security policy on top of it. We will also migrate the basic Git-based
repository to AWS CodeCommit, and will cover some best practices and troubleshooting
while dealing with issues on AWS CodeCommit.

Introducing VCS and Git


VCS comes under the category of software development, which helps a software team
manage changes to source code over time. A VCS keeps track of each and every
modification to the code in a database. If a mistake is made, the developer can compare
earlier versions of the code and fix the mistake while minimizing disturbance to the rest of
the team members.
Using AWS CodeCommit Chapter 1

The most widely used VCS in the world is Git. It's a mature and actively maintained open
source project developed by Linus Torvalds in 2005.

What is VCS?
A version control system (VCS) is the system where the changes to a file (or a set of files)
usually get recorded so that we can recall it whenever we want. In this book, we mostly
play around with the source code of software or applications, but that does not mean that
we can track the version changes to only the source code. If you are a graphic designer or
infrastructure automation worker and want to keep every version of image layout or
configuration file change, then VCS is the best thing to use.

Why VCS ?
There are lots of benefits to using VCS for a project. A few of them are mentioned here:

Collaboration: Anyone or everyone in the team can work on any file of the
project at any time. There would be no question where the latest version of a file
or the whole project is. It's in a common, central place, your version control
system.
Storing versions properly: Saving a version of a file or an entire project after
making changes is an essential habit, but without using a VCS, it will become
very tough, tedious, and error-prone. With a VCS, we can save the entire project
and mention the name of the versions as well. We can also mention the details of
the projects, and what all changes have been done in the current version as
compared to the previous version in a README file.
Restoring previous versions: If you mess up with your present code, you can
simply undo the changes in a few minutes.

There are many more features of using VCS while implementing or developing a project.

Types of VCS
The types of VCS are mentioned as follows:

Local version control system: In a local VCS, all the changes to a file are kept in
the local machine, which has a database that has all the changes to a file under
revision control, for example, Revision control system (RCS).

[8]
Using AWS CodeCommit Chapter 1

Centralized version control system: In a centralized VCS, we can collaborate


with other developers on different machines. So in these VCS, we need a single
server that contains all the versioned files and the number of clients can check out
files from that single server, for example, Subversion (SVN).
Distributed version control system: In a distributed VCS, the client not only
checks out the latest version of the file but also mirrors the whole repository.
Thus if any server dies, and these systems were collaborating via it, any of the
client repositories can be copied back to the server to restore it. An example of
this is Git.

What is Git?
Git is a distributed VCS, and it came into the picture when there was some maintenance
needed in the Linux Kernel. The Linux Kernel development community was using a
proprietary Distributed version control system (DVCS) called BitKeeper. But after some
time, the relationship between the Linux community developers and the proprietary
software BitKeeper broke down, which led to Linux community developers (in particular
Linux creator Linus Torvalds) developing their own DVCS tool called Git. They took a
radical approach that makes it different from other VCSs such as CVS and SVN.

Why Git over other VCSs?


It wouldn't be appropriate to say Git is better than SVN or any other VCS. It depends on the
scenario and the requirements of the project. But nowadays, most enterprises have chosen
Git as their VCS for the following reasons:

Distributed nature: Git has been designed as a distributed VCS, which means
every user can have a complete copy of the repository data stored locally, so they
can access the file history extremely fast. It also allows full functionality when the
user is not connected to the network, whereas in a centralized VCS, such as SVN,
only the central repository has the complete history. This means the user needs to
connect with the network to access the history from the central repository.

[9]
Using AWS CodeCommit Chapter 1

Branch handling: This is one of the major differences. Git has built-in support for
branches and strongly encourages developers to use them, whereas SVN can also
have branches, but its practice and workflow does not have the inside command.
In Git, we can have multiple branches of a repository, and in each repository, you
can carry out development, test it, and then merge, and it's in a tree fashion. In
SVN, everything is linear; whenever you add, delete, or modify any file, the
revision will just increment by one. Even if you roll back some changes in SVN, it
will be considered a new revision:

Smaller space requirements: Git repositories and working directory sizes are
very small in comparison with SVN.

[ 10 ]
Using AWS CodeCommit Chapter 1

Features of Git
The following are some of the features of Git:

Captures snapshots, not entire files: Git and other VCSs had this major
difference; VCS keeps the record of revisions in the form of a file. This means it
keeps a set of files for every revision. Git, however, has another way of
accounting for changes. Every time you commit or save the state of your project
in Git, it basically takes a snapshot of what your files look like at that very
moment and stores a reference to that snapshot. If files have not been changed,
Git does not store the file again; it stores a link to the previous identical file it has
already stored.
Data integrity: Before storing any data in a Git repository, it is first
checksummed, and is then referred to by that checksum. That means, if you carry
out any other modification in the file, then Git will have every record of every
modification. The mechanism used by Git for checksumming is known as SHA-1
hash.
SHA-1 hash looks something like this:

b52af1db10a8c915cfbb9c1a6c9679dc47052e34

States and areas: Git has three main states and views all files in three different
states:

Modified: This is the modification that has been done in the file,
but not yet written or committed in the database.
Committed: This ensures that the source code and related data are
safely stored in your local database or machine
Staged: This ensures that the modified file is added in its current
version and is ready for the next commitment.

[ 11 ]
Using AWS CodeCommit Chapter 1

How to do it...
Here are the steps and commands that will guide you through installing and setting up Git
and creating a repository in a very famous self-hosted Git, GitHub.

Installation of Git and its implementation using GitHub


1. If you want to use Git, we have to install the Git package on our system:
For Fedora distributions (RHEL/CentOS):

# yum install git

For Debian distributions (Debian/Ubuntu):

# apt-get install git

2. Configure your identity with Git because every Git commit uses this information,
for example, the following commit has been done by User awsstar and email is
[email protected]:

# git config --global user.name “awsstar”


# git config --global user.email “[email protected]

3. Check your settings. You will find the above username and email-id:

# git config --list

4. Now, let's try to create a repository on GitHub:


Hit www.github.com in your web browser and log in with your
credentials
Click on create New Repository

[ 12 ]
Using AWS CodeCommit Chapter 1

Then, we will get something like the following screenshot. We have to


mention the Repository name and a Description of the repository. After that,
we need to select Public or Private based on our requirements. When we opt
for Public, then anyone can see your repository, but you pick who can
commit; when you opt for Private, then you pick who can see and who can
commit, meaning by default it won't be visible to anyone. After that, we have
to initialize the README, where we can give a detailed description of the
project and click on Create Repository:

[ 13 ]
Exploring the Variety of Random
Documents with Different Content
functions of the plant. With the few exceptions already pointed out,
these may be generally classed as attractive colours.
Attractive Colours of Fruits.—The seeds of plants require to be
dispersed, so as to reach places favourable for germination and
growth. Some are very minute, and are carried abroad by the wind;
or they are violently expelled and scattered by the bursting of the
containing capsules. Others are downy or winged, and are carried
long distances by the gentlest breeze; or they are hooked and stick
to the fur of animals. But there is a large class of seeds which
cannot be dispersed in either of these ways, and they are mostly
contained in eatable fruits. These fruits are devoured by birds or
beasts, and the hard seeds pass through their stomachs undigested,
and, owing probably to the gentle heat and moisture to which they
have been subjected, in a condition highly favourable for
germination. The dry fruits or capsules containing the first two
classes of seeds are rarely, if ever, conspicuously coloured; whereas
the eatable fruits almost invariably acquire a bright colour as they
ripen, while at the same time they become soft and often full of
agreeable juices. Our red haws and hips, our black elderberries, our
blue sloes, and whortleberries, our white mistletoe and snowberry,
and our orange sea-buckthorn, are examples of the colour-sign of
edibility; and in every part of the world the same phenomenon is
found. Many such fruits are poisonous to man and to some animals,
but they are harmless to others; and there is probably nowhere a
brightly-coloured pulpy fruit which does not serve as food for some
species of bird or mammal.
Protective Colours of Fruits.—The nuts and other hard fruits of
large forest-trees, though often greedily eaten by animals, are not
rendered attractive to them by colour, because they are not intended
to be eaten. This is evident; for the part eaten in these cases is the
seed itself, the destruction of which must certainly be injurious to
the species. Mr. Grant Allen, in his ingenious work on Physiological
Æsthetics, well observes that the colours of all such fruits are
protective—green when on the tree, and thus hardly visible among
the foliage, but turning brown as they ripen and fall on the ground,
as filberts, chestnuts, walnuts, beech-nuts, and many others. It is
also to be noted that many of these are specially though imperfectly
protected; some by a prickly coat as in the chestnuts, or by a
nauseous covering as in the walnut; and the reason why the
protection is not carried further is probably because it is not needed,
these trees producing such vast quantities of fruit, that however
many are eaten, more than enough are always left to produce young
plants. In the case of the attractively coloured fruits, it is curious to
observe how the seeds are always of such a nature as to escape
destruction when the fruit itself is eaten. They are generally very
small and comparatively hard, as in the strawberry, gooseberry, and
fig; if a little larger, as in the grape, they are still harder and less
eatable; in the fruit of the rose (or hip) they are disagreeably hairy;
in the orange tribe excessively bitter. When the seeds are larger,
softer, and more eatable, they are protected by an excessively hard
and stony covering, as in the plum and peach tribe; or they are
inclosed in a tough horny core, as with crabs and apples. These last
are much eaten by swine, and are probably crushed and swallowed
without bruising the core or the seeds, which pass through their
bodies undigested. These fruits may also be swallowed by some of
the larger frugivorous birds; just as nutmegs are swallowed by
pigeons for the sake of the mace which incloses the nut, and which
by its brilliant red colour is an attraction as soon as the fruit has split
open, which it does upon the tree.
There is, however, one curious case of an attractively coloured
seed which has no soft eatable covering. The Abrus precatoria, or
“rosary bean,” is a leguminous shrub or small tree growing in many
tropical countries, whose pods curl up and split open on the tree,
displaying the brilliant red seeds within. It is very hard and glossy,
and is said to be, as no doubt it is, “very indigestible.” It may be that
birds, attracted by the bright colour of the seeds, swallow them, and
that they pass through their bodies undigested, and so get
dispersed. If so it would be a case among plants analogous to
mimicry among animals—an appearance of edibility put on to
deceive birds for the plant’s benefit. Perhaps it succeeds only with
young and inexperienced birds, and it would have a better chance of
success, because such deceptive appearances are very rare among
plants.
The smaller plants whose seeds simply drop upon the ground, as
in the grasses, sedges, composites, umbelliferæ, &c., always have
dry and obscurely-coloured capsules and small brown seeds. Others
whose seeds are ejected by the bursting open of their capsules, as
with the oxalis and many of the caryophyllaceæ, scrophulariaceæ,
&c., have their seeds very small and rarely or never edible.
It is to be remarked that most of the plants whose large-seeded
nuts cannot be eaten without destroying their germinating power—
as the oaks, beeches, and chestnuts—are trees of large size which
bear great quantities of fruit, and that they are long lived and have a
wide geographical range. They belong to what are called dominant
groups, and are thus able to endure having a large proportion of
their seeds destroyed with impunity. It is a suggestive fact that they
are among the most ancient of known dicotyledonous plants—oaks
and beeches going back to the Cretaceous period with little change
of type, so that it is not improbable that they may be older than any
fruit-eating mammal adapted to feed upon their fruits. The attractive
coloured fruits on the other hand, having so many special
adaptations to dispersal by birds and mammals, are probably of
more recent origin.[21] The apple and plum tribes are not known
earlier than the Miocene period; and although the record of extinct
vegetable life is extremely imperfect, and the real antiquity of these
groups is no doubt very much greater, it is not improbable that the
comparative antiquity of the fruit-bearing and nut-bearing trees may
remain unchanged by further discoveries, as has almost always
happened as regards the comparative antiquity of animal groups.
[21] I owe this remark to Mr. Grant Allen, author of Physiological
Æsthetics.

Attractive Colours of Flowers.—The colours of flowers serve to


render them visible and recognizable by insects, which are attracted
by secretions of nectar or pollen. During their visits for the purpose
of obtaining these products, insects involuntarily carry the pollen of
one flower to the stigma of another, and thus effect cross-
fertilization; which, as Mr. Darwin was the first to demonstrate,
immensely increases the vigour and fertility of the next generation of
plants. This discovery has led to the careful examination of great
numbers of flowers; and the result has been that the most
wonderful and complex arrangements have been found to exist, all
having for their object to secure that flowers shall not be self-
fertilized perpetually, but that pollen shall be carried, either
constantly or occasionally, from the flowers of one plant to those of
another. Mr. Darwin himself first worked out the details in orchids,
primulas, and some other groups; and hardly less curious
phenomena have since been found to occur even among some of
the most regularly-formed flowers. The arrangement, length, and
position of all the parts of the flower is now found to have a
purpose, and not the least remarkable portion of the phenomenon is
the great variety of ways in which the same result is obtained. After
the discoveries with regard to orchids, it was to be expected that the
irregular, tubular, and spurred flowers should present various curious
adaptations for fertilization by insect-agency. But even among the
open, cup-shaped, and quite regular flowers, in which it seemed
inevitable that the pollen must fall on the stigma and produce
constant self-fertilization, it has been found that this is often
prevented by a physiological variation—the anthers constantly
emitting their pollen either a little earlier or a little later than the
stigmas of the same flower, or of other flowers on the same plant,
were in the best state to receive it; and as individual plants in
different stations, soils, and aspects, differ somewhat in the time of
flowering, the pollen of one plant would often be conveyed by
insects to the stigmas of some other plant in a condition to be
fertilized by it. This mode of securing cross-fertilization seems so
simple and easy, that we can hardly help wondering why it did not
always come into action, and so obviate the necessity for those
elaborate, varied, and highly complex contrivances found perhaps in
the majority of coloured flowers. The answer to this of course is,
that variation sometimes occurred most freely in one part of a plant’s
organization, and sometimes in another; and that the benefit of
cross-fertilization was so great that any variation that favoured it
was preserved, and then formed the starting-point of a whole series
of further variations, resulting in those marvellous adaptations for
insect-fertilization, which have given much of their variety, elegance,
and beauty, to the floral world. For details of these adaptations we
must refer the reader to the works of Darwin, Lubbock, Hermann
Müller, and others. We have here only to deal with the part played
by colour, and by those floral structures in which colour is most
displayed.
Attractive Odours in Flowers.—The sweet odours of flowers, like
their colours, seem often to have been developed as an attraction or
guide to insect fertilizers, and the two phenomena are often
complementary to each other. Thus, many inconspicuous flowers—
like the mignonette and the sweet-violet, can be distinguished by
their odours before they attract the eye, and this may often prevent
their being passed unnoticed; while very showy flowers, and
especially those with variegated or spotted petals, are seldom sweet.
White, or very pale flowers, on the other hand, are often excessively
sweet, as exemplified by the jasmine and clematis; and many of
these are only scented at night, as is strikingly the case with the
night-smelling stock, our butterfly orchids (Habenaria chlorantha),
the greenish-yellow Daphne pontica, and many others. These white
flowers are mostly fertilized by night-flying moths; and those which
reserve their odours for the evening probably escape the visits of
diurnal insects, which would consume their nectar without effecting
fertilization. The absence of odour in showy flowers, and its
preponderance among those that are white, may be shown to be a
fact by an examination of the lists in Mr. Mongredien’s work on hardy
trees and shrubs.[22] He gives a list of about 160 species with showy
flowers, and another list of sixty species with fragrant flowers: but
only twenty of these latter are included among the showy species,
and these are almost all white flowered. Of the sixty species with
fragrant flowers, more than forty are white, and a number of others
have greenish, yellowish, or dusky and inconspicuous flowers. The
relation of white flowers to nocturnal insects is also well shown by
those which, like the evening primroses, only open their large white
blossoms after sunset. The red Martagon lily has been observed by
Mr. Hermann Müller to be fertilized by the humming-bird hawk moth,
which flies in the morning and afternoon when the colours of this
flower, exposed to the nearly horizontal rays of the sun, glow with
brilliancy, and when it also becomes very sweet-scented.
[22] Trees and Shrubs for English Plantations, by Augustus Mongredien.
Murray, 1870.

Attractive grouping of Flowers.—To the same need of


conspicuousness the combination of so many individually small
flowers into heads and bunches is probably due, producing such
broad masses as those of the elder, the guelder-rose, and most of
the Umbelliferæ, or such elegant bunches as those of the lilac,
laburnum, horse chestnut, and wistaria. In other cases minute
flowers are gathered into dense heads, as with Globularia, Jasione,
clover, and all the Compositæ; and among the latter the outer
flowers are often developed into a ray, as in the sunflowers, the
daisies, and the asters, forming a star-like compound flower, which is
itself often produced in immense profusion.
Why Alpine Flowers are so Beautiful.—The beauty of alpine
flowers is almost proverbial. It consists either in the increased size of
the individual flowers as compared with the whole plant, in
increased intensity of colour, or in the massing of small flowers into
dense cushions of bright colour; and it is only in the higher Alps,
above the limit of forests and upwards towards the perpetual snow-
line that these characteristics are fully exhibited. This effort at
conspicuousness under adverse circumstances may be traced to the
comparative scarcity of winged insects in the higher regions, and to
the necessity for attracting them from a distance. Amid the vast
slopes of debris and the huge masses of rock so prevalent in higher
mountain regions, patches of intense colour can alone make
themselves visible and serve to attract the wandering butterfly from
the valleys. Mr. Hermann Müller’s careful observations have shown,
that in the higher Alps bees and most other groups of winged insects
are almost wanting, while butterflies are tolerably abundant; and he
has discovered, that in a number of cases where a lowland flower is
adapted to be fertilized by bees, its alpine ally has had its structure
so modified as to be adapted for fertilization only by butterflies.[23]
But bees are always (in the temperate zone) far more abundant than
butterflies, and this will be another reason why flowers specially
adapted to be fertilized by the latter should be rendered unusually
conspicuous. We find, accordingly, the yellow primrose of the plains
replaced by pink and magenta-coloured alpine species; the
straggling wild pinks of the lowlands by the masses of large flowers
in such mountain species as Dianthus alpinus and D. glacialis; the
saxifrages of the high Alps with bunches of flowers a foot long as in
Saxifraga longifolia and S. cotyledon, or forming spreading masses of
flowers as in S. oppositifolia; while the soapworts, silenes, and
louseworts are equally superior to the allied species of the plains.
[23] Nature, vol. xi. pp. 32, 110.

Why Allied Species of Flowers Differ in Size and Beauty.—Again,


Dr. Müller has discovered that when there are showy and
inconspicuous species in the same genus of plants, there is often a
corresponding difference of structure, those with large and showy
flowers being quite incapable of self-fertilization, and thus depending
for their very existence on the visits of insects; while the others are
able to fertilize themselves should insects fail to visit them. We have
examples of this difference in Malva sylvestris, Epilobium
augustifolium, Polygonum bistorta, and Geranium pratense—which
have all large or showy flowers, and must be fertilized by insects—as
compared with Malva rotundifolia, Epilobium parviflorum, Polygonum
aviculare, and Geranium pusillum, which have small or inconspicuous
flowers, and are so constructed that if insects should not visit them
they are able to fertilize themselves.[24]
[24] Nature, vol. ix. p. 164.

Absence of Colour in Wind-fertilized Flowers.—As supplementing


these curious facts showing the relation of colour in flowers to the
need of the visits of insects to fertilize them, we have the
remarkable, and on any other theory, utterly inexplicable
circumstance, that in all the numerous cases in which plants are
fertilized by the agency of the wind they never have specially
coloured floral envelopes. Such are our pines, oaks, poplars, willows,
beeches, and hazel; our nettles, grasses, sedges, and many others.
In some of these the male flowers are, it is true, conspicuous, as in
the catkins of the willows and the hazel, but this arises incidentally
from the masses of pollen necessary to secure fertilization, as shown
by the entire absence of a corolla or of those coloured bracts which
so often add to the beauty and conspicuousness of true flowers.
The Same Theory of Colour Applicable to Animals and Plants.—It
may be thought that this absence of colour where it is not wanted is
opposed to the view maintained in the earlier part of the preceding
chapter, that colour is normal and is constantly tending to appear in
natural objects. It must be remembered, however, that the green
colour of foliage, due to chlorophyll, prevails throughout the greater
part of the vegetable kingdom, and has, almost certainly, persisted
through long geological periods. It has thus acquired a fixity of
character which cannot be readily disturbed; and, as a matter of
fact, we find that colour rarely appears in plants except in
association with a considerable modification of leaf-texture, such as
occurs in the petals and coloured sepals of flowers. Wind-fertilized
plants never have such specially organized floral envelopes and, in
most cases, are entirely without a calyx or corolla. The connection
between modification of leaf-structure and colour is further seen in
the greater amount and variety of colour in irregular than in regular
flowers. The latter, which are least modified, have generally uniform
or but slightly varied colours; while the former which have
undergone great modification, present an immense range of colour
and marking, culminating in the spotted and variegated flowers of
such groups as the Scrophularineæ and Orchideæ. The same laws
as to the conditions of a maximum production of colour are thus
found to obtain both in plants and animals.
Relation of the Colours of Flowers and their Geographical
Distribution.—The adaptation of flowers to be fertilized by insects—
often to such an extent that the very existence of the species
depends upon it—has had wide-spread influence on the distribution
of plants and the general aspects of vegetation. The seeds of a
particular species may be carried to another country, may find there
a suitable soil and climate, may grow and produce flowers; but if the
insect which alone can fertilize it should not inhabit that country, the
plant cannot maintain itself, however frequently it may be introduced
or however vigorously it may grow. Thus may probably be explained
the poverty in flowering-plants and the great preponderance of ferns
that distinguishes many oceanic islands, as well as the deficiency of
gaily-coloured flowers in others. This branch of the subject is
discussed at some length in my Address to the Biological Section of
the British Association,[25] but I may here just allude to two of the
most striking cases. New Zealand is, in proportion to its total number
of flowering-plants, exceedingly poor in handsome flowers, and it is
correspondingly poor in insects, especially in bees and butterflies,
the two groups which so greatly aid in fertilization. In both these
aspects it contrasts strongly with Southern Australia and Tasmania in
the same latitudes, where there is a profusion of gaily-coloured
flowers and an exceeding rich insect-fauna. The other case is
presented by the Galapagos islands, which, though situated on the
equator off the west coast of South America, and with a tolerably
luxuriant vegetation in the damp mountain zone, yet produce hardly
a single conspicuously-coloured flower; and this is correlated with,
and no doubt dependent on, an extreme poverty of insect life, not
one bee and only a single butterfly having been found there.
[25] See Chapter VII. of this volume.

Again, there is reason to believe that some portion of the large


size and corresponding showiness of tropical flowers is due to their
being fertilized by very large insects and even by birds. Tropical
sphinx-moths often have their probosces nine or ten inches long,
and we find flowers whose tubes or spurs reach about the same
length; while the giant bees, and the numerous flower-sucking birds,
aid in the fertilization of flowers whose corollas or stamens are
proportionately large.
Recent Views as to Direct Action of Light on the Colours of
Flowers and Fruits.—The theory that the brilliant colours of flowers
and fruits is due to the direct action of light, has been supported by
a recent writer by examples taken from the arctic instead of from
the tropical flora. In the arctic regions vegetation is excessively rapid
during the short summer, and this is held to be due to the
continuous action of light throughout the long summer days. “The
further we advance towards the north the more the leaves of plants
increase in size as if to absorb a greater proportion of the solar rays.
M. Grisebach says, that during a journey in Norway he observed that
the majority of deciduous trees had already, at the 60th degree of
latitude, larger leaves than in Germany, while M. Ch. Martins has
made a similar observation as regards the leguminous plants
cultivated in Lapland.”[26] The same writer goes on to say that all the
seeds of cultivated plants acquire a deeper colour the further north
they are grown, white haricots becoming brown or black, and white
wheat becoming brown, while the green colour of all vegetation
becomes more intense. The flowers also are similarly changed: those
which are white or yellow in central Europe becoming red or orange
in Norway. This is what occurs in the Alpine flora, and the cause is
said to be the same in both—the greater intensity of the sunlight. In
the one the light is more persistent, in the other more intense
because it traverses a less thickness of atmosphere.
[26] Revue des Deux Mondes, 1877. “La Vegetation dans les hautes
Latitudes,” par M. Tisserand.

Admitting the facts as above stated to be in themselves correct,


they do not by any means establish the theory founded on them;
and it is curious that Grisebach, who has been quoted by this writer
for the fact of the increased size of the foliage, gives a totally
different explanation of the more vivid colours of Arctic flowers. He
says—“We see flowers become larger and more richly coloured in
proportion as, by the increasing length of winter, insects become
rarer, and their co-operation in the act of fecundation is exposed to
more uncertain chances.” (Vegetation du Globe, vol. i. p. 61—French
translation.) This is the theory here adopted to explain the colours of
Alpine plants, and we believe there are many facts that will show it
to be the preferable one. The statement that the white and yellow
flowers of temperate Europe become red or golden in the Arctic
regions must we think be incorrect. By roughly tabulating the colours
of the plants given by Sir Joseph Hooker[27] as permanently Arctic,
we find among fifty species with more or less conspicuous flowers,
twenty-five white, twelve yellow, eight purple or blue, three lilac,
and two red or pink; showing a very similar proportion of white and
yellow flowers to what obtains further south.
[27] “On the Distribution of Arctic Plants,” Linn. Trans. vol. xxiii. (1862.)

We have, however, a remarkable flora in the Southern


Hemisphere which affords a crucial test of the theory of greater
intensity of light being the direct cause of brilliantly-coloured flowers.
The Auckland and Campbell’s Islands south of New Zealand, are in
the same latitude as the middle and the south of England, and the
summer days are therefore no longer than with us. The climate
though cold is very uniform, and the weather “very rainy and
stormy.” It is evident, then, that there can be no excess of sunshine
above what we possess; yet in a very limited flora there are a
number of flowers which—Sir Joseph Hooker states—are equal in
brilliancy to the Arctic flora. These consist of brilliant gentians,
handsome veronicas, large and magnificent Compositæ with purple
flowers, bright ranunculi, showy Umbelliferæ, and the golden
flowered Chrysobactron Rossii, one of the finest of the Asphodeleæ.
[28]
All these fine plants, it must be remembered, are peculiar to
these islands, and have therefore been developed under the climatal
conditions that prevail there; and as we have no reason to suppose
that these conditions have undergone any recent change we may be
quite sure that an excess of light has had nothing to do with the
development of these exceptionally bright and handsome flowers.
Unfortunately we have no information as to the insects of these
islands, but from their scarcity in New Zealand we can hardly expect
them to be otherwise than very scarce. There are however two
species of honey-sucking birds (Prosthemadera and Anthornis) as
well as a small warbler (Myiomoira), and we may be pretty sure that
the former at least visit these large and handsome flowers, and so
effect their fertilization. The most abundant tree on the islands is a
species of Metrosideros, and we know that trees of this genus are
common in the Pacific islands, where they are almost certainly
fertilized by the same family of Meliphagidæ or honey-sucking birds.
[28] Coloured figures of all these plants are given in the Flora
Antarctica, vol. i.

I have now concluded this sketch of the general phenomena of


colour in the organic world. I have shown reasons for believing that
its presence, in some of its infinitely-varied hues, is more probable
than its absence; and that variation of colour is an almost necessary
concomitant of variation of structure, of development, and of
growth. It has also been shown how colour has been appropriated
and modified both in the animal and vegetable worlds for the
advantage of the species in a great variety of ways, and that there is
no need to call in the aid of any other laws than those of organic
development and “natural selection” to explain its countless
modifications. From the point of view here taken it seems at once
improbable and unnecessary that the lower animals should have the
same delicate appreciation of the infinite variety and beauty—of the
delicate contrasts and subtle harmonies of colour, which are
possessed by the more intellectual races of mankind, since even the
lower human races do not possess it. All that seems required in the
case of animals, is a perception of distinctness or contrast of
colours; and the dislike of so many creatures to scarlet may perhaps
be due to the rarity of that colour in nature, and to the glaring
contrast it offers to the sober greens and browns which form the
general clothing of the earth’s surface, though it may also have a
direct irritating effect on the retina.
The general view of the subject now given must convince us
that, so far from colour being—as it has sometimes been thought to
be—unimportant, it is intimately connected with the very existence
of a large proportion of the species of the animal and vegetable
worlds. The gay colours of the butterfly and of the alpine flower
which it unconsciously fertilizes while seeking for its secreted honey,
are each beneficial to its possessor, and have been shown to be
dependent on the same class of general laws as those which have
determined the form, the structure, and the habits of every living
thing. The complex laws and unexpected relations which we have
seen to be involved in the production of the special colours of flower,
bird, and insect, must give them an additional interest for every
thoughtful mind; while the knowledge that, in all probability, each
style of coloration, and sometimes the smallest details, have a
meaning and a use, must add a new charm to the study of nature.
ON THE ORIGIN OF THE COLOUR-SENSE.

Throughout the preceding discussion we have accepted the


subjective phenomena of colour—that is, our perception of varied
hues and the mental emotions excited by them, as ultimate facts
needing no explanation. Yet they present certain features well
worthy of attention, a brief consideration of which will form a fitting
sequel to the present essay.
The perception of colour seems, to the present writer, the most
wonderful and the most mysterious of our sensations. Its extreme
diversities and exquisite beauties seem out of proportion to the
causes that are supposed to have produced them, or the physical
needs to which they minister. If we look at pure tints of red, green,
blue, and yellow, they appear so absolutely contrasted and unlike
each other, that it is almost impossible to believe (what we
nevertheless know to be the fact) that the rays of light producing
these very distinct sensations differ only in wave-length and rate of
vibration; and that there is from one to the other a continuous series
and gradation of such vibrating waves. The positive diversity we see
in them must then depend upon special adaptations in ourselves;
and the question arises—for what purpose have our visual organs
and mental perceptions become so highly specialised in this respect?
When the sense of sight was first developed in the animal
kingdom, we can hardly doubt that what was perceived was light
only, and its more or less complete withdrawal. As the sense became
perfected, more delicate gradations of light and shade would be
perceived; and there seems no reason why a visual capacity might
not have been developed as perfect as our own, or even more so in
respect of light and shade, but entirely insensible to differences of
colour except in so far as these implied a difference in the quantity
of light. The world would in that case appear somewhat as we see it
in good stereoscopic photographs; and we all know how exquisitely
beautiful such pictures are, and how completely they give us all
requisite information as to form, surface-texture, solidity, and
distance, and even to some extent as to colour; for almost all
colours are distinguishable in a photograph by some differences of
tint, and it is quite conceivable that visual organs might exist which
would differentiate what we term colour by delicate gradations of
some one characteristic neutral tint. Now such a capacity of vision
would be simple as compared with that which we actually possess;
which, besides distinguishing infinite gradations of the quantity of
light, distinguishes also, by a totally distinct set of sensations,
gradations of quality, as determined by differences of wave-lengths
or rate of vibration. At what grade in animal development this new
and more complex sense first began to appear we have no means of
determining. The fact that the higher vertebrates, and even some
insects, distinguish what are to us diversities of colour, by no means
proves that their sensations of colour bear any resemblance
whatever to ours. An insect’s capacity to distinguish red from blue or
yellow may be (and probably is) due to perceptions of a totally
distinct nature, and quite unaccompanied by any of that sense of
enjoyment or even of radical distinctness which pure colours excite
in us. Mammalia and birds, whose structure and emotions are so
similar to our own, do probably receive somewhat similar
impressions of colour; but we have no evidence to show that they
experience pleasurable emotions from colour itself, when not
associated with the satisfaction of their wants or the gratification of
their passions.
The primary necessity which led to the development of the sense
of colour, was probably the need of distinguishing objects much alike
in form and size, but differing in important properties;—such as ripe
and unripe, or eatable and poisonous fruits; flowers with honey or
without; the sexes of the same or of closely allied species. In most
cases the strongest contrast would be the most useful, especially as
the colours of the objects to be distinguished would form but minute
spots or points when compared with the broad masses of tint of sky,
earth, or foliage against which they would be set.
Throughout the long epochs in which the sense of sight was
being gradually developed in the higher animals, their visual organs
would be mainly subjected to two groups of rays—the green from
vegetation, and the blue from the sky. The immense preponderance
of these over all other groups of rays would naturally lead the eye to
become specially adapted for their perception; and it is quite
possible that at first these were the only kinds of light-vibrations
which could be perceived at all. When the need for differentiation of
colour arose, rays of greater and of smaller wave-lengths would
necessarily be made use of to excite the new sensations required;
and we can thus understand why green and blue form the central
portion of the visible spectrum, and are the colours which are most
agreeable to us in large surfaces; while at its two extremities we find
yellow, red, and violet—colours which we best appreciate in smaller
masses, and when contrasted with the other two, or with light
neutral tints. We have here probably the foundations of a natural
theory of harmonious colouring, derived from the order in which our
colour-sensations have arisen and the nature of the emotions with
which the several tints have been always associated. The agreeable
and soothing influence of green light may be in part due to the
green rays having little heating power; but this can hardly be the
chief cause, for the blue and violet, though they contain less heat,
are not generally felt to be so cool and sedative. But when we
consider how dependent are all the higher animals on vegetation,
and that man himself has been developed in the closest relation to
it, we shall find, probably, a sufficient explanation. The green mantle
with which the earth is overspread caused this one colour to
predominate over all others that meet our sight, and to be almost
always associated with the satisfaction of human wants. Where the
grass is greenest, and vegetation most abundant and varied, there
has man always found his most suitable dwelling-place. In such
spots hunger and thirst are unknown, and the choicest productions
of nature gratify the appetite and please the eye. In the greatest
heats of summer, coolness, shade, and moisture are found in the
green forest glades; and we can thus understand how our visual
apparatus has become especially adapted to receive pleasurable and
soothing sensations from this class of rays.
Supposed increase of Colour-perception within the Historical
Period.—Some writers believe that our power of distinguishing
colours has increased even in historical times. The subject has
attracted the attention of German philologists, and I have been
furnished by a friend with some notes from a work of the late
Lazarus Geiger, entitled, Zur Entwickelungsgeschichte der
Menschheit (Stuttgart, 1871). According to this writer it appears that
the colour of grass and foliage is never alluded to as a beauty in the
Vedas or the Zendavesta, though these productions are continually
extolled for other properties. Blue is described by terms denoting
sometimes green, sometimes black, showing that it was hardly
recognised as a distinct colour. The colour of the sky is never
mentioned in the Bible, the Vedas, the Homeric poems, or even in
the Koran. The first distinct allusion to it known to Geiger is in an
Arabic work of the ninth century. “Hyacinthine locks” are black locks,
and Homer calls iron “violet-coloured.” Yellow was often confounded
with green; but, along with red, it was one of the earliest colours to
receive a distinct name. Aristotle names three colours in the rainbow
—red, yellow, and green. Two centuries earlier Xenophanes had
described the rainbow as purple, reddish, and yellow. The
Pythagoreans admitted four primary colours—white, black, red, and
yellow; the Chinese the same, with the addition of green.
Simultaneously with the first publication of this essay in
Macmillan’s Magazine, there appeared in the Nineteenth Century an
article by Mr. Gladstone on the Colour-sense, chiefly as exhibited in
the poems of Homer. He shows that the few colour-terms used by
Homer are applied to such different objects that they cannot denote
colours only, as we perceive and differentiate them; but seem more
applicable to different intensities of light and shade. Thus, to give
one example, the word porphureos is applied to clothing, to the
rainbow, to blood, to a cloud, to the sea, and to death; and no one
meaning will suit all these applications except comparative darkness.
In other cases the same thing has many different epithets applied to
it according to its different aspects or conditions; and as the colours
of objects are generally indicated in ancient writings by comparative
rather than by abstract terms,—as wine-colour, fire-colour, bronze-
colour, &c.—it becomes still more difficult to determine in any
particular case what colour was really meant. Mr. Gladstone’s general
conclusion is, that the archaic man had a positive perception only of
degrees of light and darkness, and that in Homer’s time he had
advanced to the imperfect discrimination of red and yellow, but no
further; the green of grass and foliage or the blue of the sky being
never once referred to.
These curious facts cannot, however, be held to prove so recent
an origin for colour-sensations as they would at first sight appear to
do, because we have seen that both flowers and fruits have become
diversely coloured in adaptation to the visual powers of insects,
birds, and mammals. Red, being a very common colour of ripe fruits
which attract birds to devour them and thus distribute their seeds,
we may be sure that the contrast of red and green is to them very
well marked. It is indeed just possible that birds may have a more
advanced development of the colour-sense than mammals, because
the teeth of the latter commonly grind up and destroy the seeds of
the larger fruits and nuts which they devour, and which are not
usually coloured; but the irritating effect of bright colours on some
of them does not support this view. It seems most probable
therefore that man’s perception of colour in the time of Homer was
little if any inferior to what it is now, but that, owing to a variety of
causes, no precise nomenclature of colours had become established.
One of these causes probably was, that the colours of the objects of
most importance, and those which were most frequently referred to
in songs and poems, were uncertain and subject to variation. Blood
was light or dark red, or when dry, blackish; iron was grey or dark or
rusty; bronze was shining or dull; foliage was of all shades of yellow,
green, or brown; and horses or cattle had no one distinctive colour.
Other objects, as the sea, the sky, and wine, changed in tint
according to the light, the time of day, and the mode of viewing
them; and thus colour, indicated at first by reference to certain
coloured objects, had no fixity. Things which had more definite and
purer colours—as certain species of flowers, birds, and insects—were
probably too insignificant or too much despised to serve as colour-
terms; and even these often vary, either in the same or in allied
species, in a manner which would render their use unsuitable.
Colour-names, being abstractions, must always have been a late
development in language, and their comparative unimportance in an
early state of society and of the arts would still further retard their
appearance; and this seems quite in accordance with the various
facts set forth by Mr. Gladstone and the other writers referred to.
The fact that colour-blindness is so prevalent even now, is however
an indication that the fully developed colour-sense is not of primary
importance to man. If it had been so, natural selection would long
ago have eliminated the disease itself, and its tendency to recur
would hardly be so strong as it appears to be.
Concluding Remarks on the Colour-sense.—The preceding
considerations enable us to comprehend, both why a perception of
difference of colour has become developed in the higher animals,
and also why colours require to be presented or combined in varying
proportions in order to be agreeable to us. But they hardly seem to
afford a sufficient explanation, either of the wonderful contrasts and
total unlikeness of the sensations produced in us by the chief
primary colours, or of the exquisite charm and pleasure we derive
from colour itself, as distinguished from variously-coloured objects,
in the case of which association of ideas comes into play. It is hardly
conceivable that the material uses of colour to animals and to
ourselves, required such very distinct and powerfully-contrasted
sensations; and it is still less conceivable that a sense of delight in
colour per se should have been necessary for our utilization of it.
The emotions excited by colour and by music, alike, seem to rise
above the level of a world developed on purely utilitarian principles.
VII.

BY-PATHS IN THE DOMAIN OF BIOLOGY:


BEING AN ADDRESS DELIVERED TO THE BIOLOGICAL SECTION OF THE BRITISH
ASSOCIATION, (GLASGOW, SEPTEMBER 6TH, 1876,) AS PRESIDENT OF THE
SECTION.
Introductory Remarks—On some Relations of Living Things to their Environment—The
Influence of Locality on Colour in Butterflies and Birds—Sense-perception
influenced by Colour of the Integuments—Relations of Insular Plants and
Insects—Rise and Progress of Modern Views as to the Antiquity and Origin of
Man—Indications of Man’s extreme Antiquity—Antiquity of Intellectual Man—
Sculptures on Easter-Island—North American Earthworks—The Great Pyramid
—Conclusion.

The range of subjects comprehended within the domain of Biology is


so wide, and my own acquaintance with them so imperfect, that it is
not in my power to lay before you any general outline of the recent
progress of the biological sciences. Neither do I feel competent to
give you a summary of the present status of any one of the great
divisions of our science, such as Anatomy, Physiology, Embryology,
Histology, Classification, or Evolution—Philology, Ethnology, or
Prehistoric Archæology; but there are fortunately several outlying
and more or less neglected subjects to which I have for some time
had my attention directed, and which I hope will furnish matter for a
few observations, of some interest to biologists and at the same
time not unintelligible to the less scientific members of the
Association who may honour us with their presence.
The subjects I first propose to consider have no general name,
and are not easily grouped under a single descriptive heading; but
they may be compared with that recent development of a sister
science which has been termed surface-geology or Earth-sculpture.
In the older geological works we learnt much about strata, and
rocks, and fossils, their superposition, contortions, chemical
constitution, and affinities, with some general notions of how they
were formed in the remote past; but we often came to the end of
the volume no whit the wiser as to how and why the surface of the
earth came to be so wonderfully and beautifully diversified; we were
not told why some mountains are rounded and others precipitous;
why some valleys are wide and open, others narrow and rocky; why
rivers so often pierce through mountain-chains; why mountain-lakes
are often so enormously deep; whence came the gravel, and drift,
and erratic blocks so strangely spread over wide areas while totally
absent from other areas equally extensive. So long as these
questions were almost ignored, geology could hardly claim to be a
complete science, because, while professing to explain how the crust
of the earth came to be what it is, it gave no intelligible account of
many phenomena presented by its surface. But of late years these
surface-phenomena have been assiduously studied; the marvellous
effects of denudation and glacial action in giving the final touches to
the actual contour of the earth’s surface, and their relation to
climatic changes and the antiquity of man, have been clearly traced,
thus investing geology with a new and popular interest, and at the
same time elucidating many of the phenomena presented in the
older formations.
Now just as a surface-geology was required to complete that
science, so a surface-biology was wanted to make the science of
living things more complete and more generally interesting, by
applying the results arrived at by special workers to the
interpretation of those external and prominent features whose
endless variety and beauty constitute the charm which attracts us to
the contemplation or to the study of nature. We have the descriptive
zoologist, for example, who gives us the external characters of
animals; the anatomist studies their internal structure; the histologist
makes known the nature of their component tissues; the
embryologist patiently watches the progress of their development;
the systematist groups them into classes and orders, families,
genera, and species; while the field-naturalist studies for us their
food and habits and general economy. But, till quite recently, none of
these earnest students nor all of them combined, could answer
satisfactorily, or even attempted to answer, many of the simplest
questions concerning the external characters and general relations of
animals and plants. Why are flowers so wonderfully varied in form
and colour? what causes the Arctic fox and the ptarmigan to turn
white in winter? why are there no elephants in America and no deer
in Australia? why are closely allied species rarely found together?
why are male animals so frequently bright-coloured? why are extinct
animals so often larger than those which are now living? what has
led to the production of the gorgeous train of the peacock and of the
two kinds of flower in the primrose? The solution of these and a
hundred other problems of like nature was rarely approached by the
old method of study, or if approached was only the subject of vague
speculation. It is to the illustrious author of the Origin of Species
that we are indebted for teaching us how to study nature as one
great, compact, and beautifully-adjusted system. Under the touch of
his magic wand the countless isolated facts of internal and external
structure of living things—their habits, their colours, their
development, their distribution, their geological history,—all fell into
their approximate places; and although, from the intricacy of the
subject and our very imperfect knowledge of the facts themselves,
much still remains uncertain, yet we can no longer doubt that even
the minutest and most superficial peculiarities of animals and plants
either, on the one hand, are or have been useful to them, or, on the
other hand, have been developed under the influence of general
laws, which we may one day understand to a much greater extent
than we do at present. So great is the alteration effected in our
comprehension of nature by the study of variation, inheritance,
cross-breeding, competition, distribution, protection, and selection—
showing, as they often do, the meaning of the most obscure
phenomena and the mutual dependence of the most widely-
separated organisms—that it can only be fitly compared with the
analogous alteration produced in our conception of the universe by
Newton’s grand discovery of the law of gravitation.
I know it will be said (and is said), that Darwin is too highly
rated, that some of his theories are wholly and others partially
erroneous, and that he often builds a vast superstructure on a very
uncertain basis of doubtfully interpreted facts. Now, even admitting
this criticism to be well founded—and I myself believe that to a
limited extent it is so—I nevertheless maintain that Darwin is not
and cannot be too highly rated; for his greatness does not at all
depend upon his being infallible, but on his having developed, with
rare patience and judgment, a new system of observation and study,
guided by certain general principles which are almost as simple as
gravitation and as wide-reaching in their effects. And if other
principles should hereafter be discovered, or if it be proved that
some of his subsidiary theories are wholly or partially erroneous, this
very discovery can only be made by following in Darwin’s steps, by
adopting the method of research which he has taught us, and by
largely using the rich stores of material which he has collected. The
Origin of Species, and the grand series of works which have
succeeded it, have revolutionized the study of biology; they have
given us new ideas and fertile principles; they have infused life and
vigour into our science, and have opened up hitherto unthought-of
lines of research on which hundreds of eager students are now
labouring. Whatever modifications some of his theories may require,
Darwin must none the less be looked up to as the founder of
philosophical biology.
As a small contribution to this great subject, I propose now to
call your attention to some curious relations of organisms to their
environment, which seem to me worthy of more systematic study
than has hitherto been given them. The points I shall more
especially deal with are—the influence of locality, or of some
unknown local causes, in determining the colours of insects, and, to
a less extent, of birds; and the way in which certain peculiarities in
the distribution of plants may have been brought about by their
dependence on insects. The latter part of my address will deal with
the present state of our knowledge as to the antiquity and early
history of mankind.
ON SOME RELATIONS OF LIVING THINGS TO THEIR ENVIRONMENT.

Of all the external characters of animals, the most beautiful, the


most varied, and the most generally attractive are the brilliant
colours and strange yet often elegant markings with which so many
of them are adorned. Yet of all characters this is the most difficult to
bring under the laws of utility or of physical connection. Mr. Darwin—
as you are well aware—has shown how wide is the influence of sex
on the intensity of coloration; and he has been led to the conclusion
that active or voluntary sexual selection is one of the chief causes, if
not the chief cause, of all the variety and beauty of colour we see
among the higher animals. This is one of the points on which there
is much divergence of opinion even among the supporters of Mr.
Darwin, and one as to which I myself differ from him. I have argued,
and still believe, that the need of protection is a far more efficient
cause of variation of colour than is generally suspected; but there
are evidently other causes at work, and one of these seems to be an
influence depending strictly on locality, whose nature we cannot yet
understand, but whose effects are everywhere to be seen when
carefully searched for.
Although the careful experiments of Sir John Lubbock have
shown that insects can distinguish colours—as might have been
inferred from the brilliant colours of the flowers which are such an
attraction to them—yet we can hardly believe that their appreciation
and love of distinctive colours is so refined as to guide and regulate
their most powerful instinct—that of reproduction. We are therefore
led to seek some other cause for the varied colours that prevail
among insects; and as this variety is most conspicuous among
butterflies—a group perhaps better known than any other—it offers
the best means of studying the subject. The variety of colour and
marking among these insects is something marvellous. There are
probably about ten thousand different kinds of butterflies now
known, and about half of these are so distinct in colour and marking
that they can be readily distinguished by this means alone. Almost
every conceivable tint and pattern is represented, and the hues are
often of such intense brilliance and purity as can be equalled by
neither birds nor flowers.
Any help to a comprehension of the causes which may have
concurred in bringing about so much diversity and beauty must be of
value; and this is my excuse for laying before you the more
important cases I have met with of a connection between colour and
locality.
The influence of Locality on Colour in Butterflies and Birds.—Our
first example is from tropical Africa, where we find two unrelated
groups of butterflies belonging to two very distinct families
(Nymphalidæ and Papilionidæ) characterized by a prevailing blue-
green colour not found in any other continent.[29] Again, we have a
group of African Pieridæ which are white or pale yellow with a
marginal row of bead-like black spots; and in the same country one
of the Lycænidæ (Leptena erastus) is coloured so exactly like these
that it was at first described as a species of Pieris. None of these
four groups are known to be in any way specially protected, so that
the resemblance cannot be due to protective mimicry.
[29] Romaleosoma and Euryphene (Nymphalidæ), Papilio zalmoxis and
several species of the Nireus-group (Papilionidæ).

In South America we have far more striking cases; for in the


three subfamilies Danainæ, Acræinæ, and Heliconiinæ, all of which
are specially protected, we find identical tints and patterns
reproduced, often in the greatest detail, each peculiar type of
coloration being characteristic of separate geographical subdivisions
of the continent. Nine very distinct genera are implicated in these
parallel changes—Lycorea, Ceratinia, Mechanitis, Ithomia, Melinæa,
Tithorea, Acræa, Heliconius, and Eueides, groups of three or four (or
even five) of them appearing together in the same livery in one
district, while in an adjoining district most or all of them undergo a
simultaneous change of coloration or of marking. Thus in the genera
Ithomia, Mechanitis, and Heliconius we have species with yellow
apical spots in Guiana, all represented by allied species with white
apical spots in South Brazil. In Mechanitis, Melinæa, and Heliconius,
and sometimes in Tithorea, the species of the Southern Andes
(Bolivia and Peru) are characterized by an orange and black livery,
while those of the Northern Andes (New Granada) are almost always
orange-yellow and black. Other changes of a like nature, which it
would be tedious to enumerate but which are very striking when
specimens are examined, occur in species of the same groups
inhabiting these same localities, as well as Central America and the
Antilles. The resemblance thus produced between widely different
insects is sometimes general, but often so close and minute that
only a critical examination of structure can detect the difference
between them. Yet this can hardly be true mimicry, because all are
alike protected by the nauseous secretion which renders them
unpalatable to birds.
In another series of genera (Catagramma, Callithea, and Agrias)
all belonging to the Nymphalidæ, we have the most vivid blue
ground, with broad bands of orange, crimson or a different tint of
blue or purple, exactly reproduced in corresponding, yet unrelated
species, occurring in the same locality; yet, as none of these groups
are known to be specially protected, this can hardly be true mimicry.
A few species of two other genera in the same country (Eunica and
Siderone) also reproduce the same colours, but with only a general
resemblance in the markings. Yet again, in tropical America we have
species of Apatura which, sometimes in both sexes, sometimes in
the female only, exactly imitate the peculiar markings of another
genus (Heterochroa) confined to America: here, again, neither genus
is protected, and the similarity must be due to unknown local
causes.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like