GithubHelp home page GithubHelp logo

awsdocs / elastic-beanstalk-samples Goto Github PK

View Code? Open in Web Editor NEW
1.2K 70.0 890.0 965 KB

This repository contains code and configuration samples (e.g. .ebextensions) for AWS Elastic Beanstalk.

License: Apache License 2.0

Python 100.00%

elastic-beanstalk-samples's Introduction

elastic-beanstalk-samples

This repository complements the AWS Elastic Beanstalk documentation. It contains examples of configuration files (.ebextensions) and AWS CloudFormation templates that you can use to improve your Elastic Beanstalk applications.

To use a configuration file, create a folder named .ebextensions in the root of your application source and save the .config file from the repository in that folder. Follow the instructions in the configuration file to make it work with your application. Then deploy your application to an Elastic Beanstalk, and make sure you include the .ebextensions folder in your source bundle.

To use a CloudFormation template, use the CloudFormation console to create a stack from the template. The templates in this repo create resources that you may want to manage independently of your Elastic Beanstalk environment. For example, you can create a VPC to run multiple environments in, and not worry about losing it when you terminate an environment.

You can report issues, make pull requests, and contribute your own resources to help other AWS Elastic Beanstalk customers use the service. We are committed to helping developers learn more about Beanstalk, and we hope you find the this forum useful. Please don't hesitate to let us know how we can improve it to be more useful.

The full set of Elastic Beanstalk documents is at http://aws.amazon.com/documentation/elastic-beanstalk/.

Sample applications

Sample applications that show the use of additional web frameworks, libraries and tools are available as open source projects on GitHub.

AWS-provided sample applications

  • Load Balanced WordPress (tutorial) – Configuration files for installing WordPress securely and running it in a load balanced AWS Elastic Beanstalk environment.
  • Load Balanced Drupal (tutorial) – Configuration files and instructions for installing Drupal securely and running it in a load balanced AWS Elastic Beanstalk environment.
  • Scorekeep - RESTful web API that uses the Spring framework and the AWS SDK for Java to provide an interface for creating and managing users, sessions, and games. The API is bundled with an Angular 1.5 web app that consumes the API over HTTP. Includes branches that show integration with Amazon Cognito, AWS X-Ray, and Amazon Relational Database Service. The application uses features of the Java SE platform to download dependencies and build on-instance, minimizing the size of the souce bundle. The application also includes nginx configuration files that override the default configuration to serve the frontend web app statically on port 80 through the proxy, and route requests to paths under /api to the API running on localhost:5000.
  • Does it Have Snakes? - Tomcat application that shows the use of RDS in a Java EE web application in AWS Elastic Beanstalk. The project shows the use of Servlets, JSPs, Simple Tag Support, Tag Files, JDBC, SQL, Log4J, Bootstrap, Jackson, and Elastic Beanstalk configuration files.
  • Locust Load Generator - This project shows the use of Java SE platform features to install and run Locust, a load generating tool written in Python. The project includes configuration files that install and configure Locust, a build script that configures a DynamoDB table, and a Procfile that runs Locust.
  • Share Your Thoughts (tutorial) - PHP application that shows the use of MySQL on Amazon RDS, Composer, and configuration files.
  • A New Startup (tutorial) - Node.js sample application that shows the use of DynamoDB, the AWS SDK for JavaScript in Node.js, npm package management, and configuration files.
  • Cognito Quickstart - an AngularV4-based QuickStart web app utilizing Amazon Cognito, S3 or Elastic Beanstalk, and DynamoDB (serverless architecture).

Community-provided sample applications

  • go-beanstalk-gin - Demonstrates the deployment of a simple webapp built using gin to Elastic Beanstalk. Dependencies are managed using dep. Provided by Suhas Karanth.

elastic-beanstalk-samples's People

Contributors

ahuarte47 avatar alejandro-du avatar awsrandall avatar beckandros avatar dankhen avatar garithd avatar gepoggio avatar hayd avatar hrnatha avatar hyandell avatar ivallhon avatar jeffgardnerdev avatar jitsinj avatar joaolpalma avatar johnzprod avatar joshbean avatar jpswade avatar karan6190 avatar kitwalker12 avatar kylegalbraith avatar mcdwil avatar mosheeshel avatar moturupraveenbhargav avatar mrenneke-amazon avatar mwunderl avatar philayres avatar pioto avatar rmedeir avatar rsmets avatar samseen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elastic-beanstalk-samples's Issues

chef on beanstalk

Pls include my chef integration with Beanstalk Windows instances:
cbanciu667/cos_beanstalk/ChefClient.config.yaml

I also have an example with Oracle Client installation

cron-linux.config cannot be deployed

If you put the cron-linux.config sample in .ebextensions, you get this when running eb deploy:

2019-04-14 14:57:55    INFO    Environment update is starting.      
2019-04-14 14:57:57    ERROR   The configuration file .ebextensions/cron-linux.config in application version app-f761-190414_202746 contains invalid YAML or JSON. YAML exception: Invalid Yaml: while parsing a block mapping
 in "", line 1, column 1:
    files:
    ^
expected , but found BlockMappingStart
 in "", line 9, column 4:
       "/usr/local/bin/myscript.sh":
       ^
, JSON exception: Invalid JSON: Unexpected character (f) at position 0.. Update the configuration file.
2019-04-14 14:57:57    ERROR   Failed to deploy application.        
                                                                      
ERROR: ServiceError - Failed to deploy application.

Update elastic beanstalk rds-ssl-java.config for use with new certs

The rds-ssl-java.config is still using the 2015 cert. With the deprecation underway, I think both should be added in, and eventually stop adding the 2015 cert.

Happy to do it when I get some free time as it's a little time-consuming to make sure everything is working properly with the uploading of a new version, downloading logs, etc.

Instancecert input

when adding the instancecert for nodejs to my .ebextensions folder, what do I put in the following area. My certificate is a public one issues by AWS certificate manager.

Default: |
-----BEGIN CERTIFICATE-----
Paste your public certificate content here
-----END CERTIFICATE-----

Websockets with ALB and Ruby Passenger failed.

Hi,
We are using "64bit Amazon Linux 2017.09 v2.7.1 running Ruby 2.3 (Passenger Standalone)" configuration.
Added an ALB and tried to test Websockets and got "WebSocket is closed before the connection is established."

When switched to "Puma" stack, and added the NGINX config mentioned below, everything is working as expected.
https://github.com/awslabs/elastic-beanstalk-samples/blob/dd644f00e087b6b50e7ad0f69b6334f1dcc7cde7/configuration-files/aws-provided/instance-configuration/websockets/ruby-puma/websockets-ruby-puma.config

EFS Mount Permission

I am using this config for EB: https://github.com/awslabs/elastic-beanstalk-docs/blob/master/configuration-files/aws-provided/instance-configuration/storage-efs-mountfilesystem.config

It doesn't set the permissions for the MOUNT_DIRECTORY correctly. I have to login manually and do a sudo chmod 777 to get it to work.

I have had a look at the code:

if [ ! -d ${EFS_MOUNT_DIR} ]; then echo "Creating directory ${EFS_MOUNT_DIR} ..." mkdir -p ${EFS_MOUNT_DIR} if [ $? -ne 0 ]; then echo 'ERROR: Directory creation failed!' exit 1 fi chmod 777 ${EFS_MOUNT_DIR} if [ $? -ne 0 ]; then echo 'ERROR: Permission update failed!' exit 1 fi else echo "Directory ${EFS_MOUNT_DIR} already exists!" fi

You are doing chmod 777, and it isn't throwing any kind of error.

It is going into that condition too:

Mounting EFS filesystem to directory /efs ... Stopping NFS ID Mapper... rpc.idmapd is already stopped! Checking if EFS mount directory exists... Creating directory /efs ... mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-xxx.efs.us-west-2.amazonaws.com:/ /efs EFS mount complete.

Service:AmazonCloudFormation, Message:Template format error: Unresolved resource dependencies [fs-****] in the Resources block of the template

Using the example storage-efs-mountfilesystem.config to mount EFS on EB, I experience this error:

Service:AmazonCloudFormation, Message:Template format error: Unresolved resource dependencies [fs-****] in the Resources block of the template

After reading about the same error in this forum thread, I tried changing the original FILE_SYSTEM_ID format...

FILE_SYSTEM_ID: '`{"Ref" : "fs-****"}`'

to match the example in the thread...

FILE_SYSTEM_ID: fs-****

Which works successfully.

Is it possible that the example is incorrect? The load-balanced Wordpress on EB example also seems to have this issue.

Missing post-installation commands

Hello,

this documentation is missing an important part of Symfony deployments, which are the post installation commands for warming up the cache, removing app_dev.php (if required) and checking that the server is properly configured (php bin/console doctrine:ensure-production-settings --env=prod).

When and how should these post-installation steps be performed?

issue on autoscaling-memory-utlization

i've deployed autoscaling-memory-utlization.config on my environment.

metrics work well, but the alarm always says it has insufficient data.

my guess would be that the metrics are not found, as of this two lines:

      Dimensions:
        - Name: AutoScalingGroupName
          Value: { "Ref" : "AWSEBAutoScalingGroup" }

as the AutoScalingGroupName has no MemoryUtilization metric, it gets no data.

is this right?

403 response from EB running with Tomcat8/Java8.

Hey folks,

I'm running into this weird issue that I never seen before and wondering if someone can shed some light.

So I deployed an elastic beanstalk environment with tomcat8/Java8 as the platform.

I uploaded the WAR file, accessed the box via SSH all is well, deployed the MySQL server, build my tables and what not, everything is functional. However, the issue is when I send a request by postman I get the following response:

{

"status": 403,

"error": "Forbidden",

"message": "Access Denied",

}

The weird thing is that I have an EC2 instance running on it's own without an EB environment and it does function without any problems. I hit that API and it returns a valid response for me. Same DB same war file and same version of tomcat8.

I couldn't really think of much but to check the EB logs and the below caught my attention - if so what could be causing it? I never seen it before even in my line of work.

Mon Apr 20 03:29:19.380050 2020 https://forums.aws.amazon.com/ https://forums.aws.amazon.com/ (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (localhost) failed

Mon Apr 20 03:29:19.380090 2020 https://forums.aws.amazon.com/ https://forums.aws.amazon.com/ client 162.243.131.92:55570 AH01114: HTTP: failed to make connection to backend: localhost

I would be grateful if someone could point me in the right direction as I'm super puzzled into what's the possible cause here. As I mentioned that same WAR file returns valid responses when hitting the end point that runs on the EC2 instance and my last suspect is the Ngnix server.

Using the default KmsKey value in storage-efs-createfilesystem.config causes deployment to fail

I used Encrypted: "false" and KmsKey: "" and got the validation message below:

1 validation error detected: Value '' at 'kmsKeyId' failed to satisfy constraint: Member must have length greater than or equal to 1

This prevented the creation of the filesystem. When I removed the Encrypted and KmsKeyId sections from the FileSystem properties then the deployment worked fine. However, these were below the line stating "Do not modify values below this line".

Yum does not have perl-Bundle-LWP available for installation

Full traceback

Unhandled exception during build: Yum does not have perl-Bundle-LWP available for installation
Traceback (most recent call last):
  File "/opt/aws/bin/cfn-init", line 171, in <module>
    worklog.build(metadata, configSets)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 129, in build
    Contractor(metadata).build(configSets, self)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 530, in build
    self.run_config(config, worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 229, in build
    changes['packages'][manager] = CloudFormationCarpenter._packageTools[manager]().apply(packages, self._auth_config)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/rpm_tools.py", line 74, in apply
    raise ToolError("Yum does not have %s available for installation" % pkg_spec)
ToolError: Yum does not have perl-Bundle-LWP available for installation

This happens when using the script https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/resource-configuration/autoscaling-memory-utlization.config on the platform Docker running on 64bit Amazon Linux 2/3.0.0.

Running yum search on the instance results in

$ yum search all perl-Bundle-LWP
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Warning: No matches found for: perl-Bundle-LWP
No matches found

What is the fix/workaround?

EB: create aws resources with custom Names (lb, ASG, LC ..)

hello,

my case is that I want to create a web environment with custom names that I specify for the Load balancer, Autoscaling group, launch configuration since I want to use that in filtering for monitoring.
for the moment EB it generates those names with ids.

How to Load mod_rewrite.so in apache EB

I wold like to know how I load rewrite_module: "LoadModule rewrite_module modules/mod_rewrite.so".

I was in my os editing the file [apache2/httpd.conf] in AWS EB not start the module.

What I need to do?

Python https redirect is not wokring for flask Python 3.6 running on 64bit Amazon Linux/2.7.6.

I was getting 500 errors with the sample flask application using the current ebextension found here

https://github.com/awsdocs/elastic-beanstalk-samples/blob/117f05fd23c0598ac7c5bdf025c2203940aeffca/configuration-files/aws-provided/security-configuration/https-redirect/python/https-redirect-python.config

Attached is the sample flask application with working https redirect for Python 3.6 running on 64bit Amazon Linux/2.7.6.
upload.zip

I believe the config.py script has been changed in the update.

Property HealthyThreshold cannot be empty.

Hello, when I use aws-provided/resource-configuration/loadbalancer-accesslogs-existingbucket.config

I have encountered the "Creating load balancer failed Reason: Property HealthyThreshold cannot be empty."

Thanks.

Logs aren't streamed to CloudWatch

Hello together,

I'm using this config file: https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/instance-configuration/logs-streamtocloudwatch-linux.config

and this config file:

## set up custom logging for nginx and php-fpm

packages:
  yum:
    awslogs: []

files:
  "/etc/awslogs/awscli.conf":
    mode: "000600"
    owner: root
    group: root
    content: |
      [plugins]
      cwlogs = cwlogs
      [default]
      region = `{"Ref":"AWS::Region"}`

  "/etc/awslogs/awslogs.conf":
    mode: "000600"
    owner: root
    group: root
    content: |
      [general]
      state_file = /var/lib/awslogs/agent-state

files:
  "/etc/awslogs/config/logs.conf":
    mode: "000600"
    owner: root
    group: root
    content: |
      [/var/php-fpm/7.1/error.log]
      log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/log/php-fpm/7.1/error.log"]]}`
      log_stream_name = {instance_id}
      file = /var/log/php-fpm/7.1/error.log

      [/var/log/nginx/access.log]
      log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/log/nginx/access.log "]]}`
      log_stream_name = {instance_id}
      file = /var/log/nginx/access.log

      [/var/log/nginx/error.log]
      log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/log/nginx/error.log "]]}`
      log_stream_name = {instance_id}
      file = /var/log/nginx/error.log

commands:
  "01":
    command: chkconfig awslogs on
  "02":
    command: service awslogs restart

But CloudWatch doesn't show up any of these logs. May there be some security settings that I've missed?

If I ssh into my instances and running sudo service awslogs status, everything seems fine: awslogs (pid 13278) is running...

Insufficient data

Hello.

Thank you. Your script and config files help me a lot.
Maybe I have found a little problem.
I'm trying to use the autoscaling-memory-utilization.config, but I had a problem. The alarm that is created shows insufficient data, reading the config file I realized that the alarm search for information about a metric called MemoryUtilization however, this metric does not exist and is not created by the script, so the alarm will always be in insufficient data and the scaling will never happen by memory.
Thank you.

Symfony 2 deployment configuration

Part of the deployment for Symfony 2/3 is handling the app configuration (as stored in app/config/parameters.yml and templated by app/config/parameters.yml.dist). At the moment, the process defaults to the values in parameters.yml.dist, which is meant to be committed to VC and to contain only placeholder or null values for sensitive parameters (e.g. db user/password, api keys, etc).

Could the documentation be expanded to include a section about how to properly handle app config with EB? Or, if that information is available in another article, could a mention and link be made?

How to configure Dockerrun.aws.json for multicontainer docker microservices app?

I have two microservices images, a Go Rest API and a React frontend which are both inside my AWS ECR. I'll be using Elastic Beanstalk. Now since I believe they're on same machine so I configured the React app to fetch data from the API on localhost:8080. Below are the Dockerfiles for both. They worked in my dev environment so I pushed them to my ECR.

Dockerfile for Golang Rest API

FROM golang
ADD . /go/src/vsts/project/gorestapi
WORKDIR /go/src/vsts/project/gorestapi
RUN go get github.com/golang/dep/cmd/dep
RUN dep ensure
RUN go install .
ENTRYPOINT /go/bin/gorestapi
EXPOSE 8080

Dockerfile for React Frontend App

FROM node:8.4.0-alpine
WORKDIR /usr/src/app
ENV NPM_CONFIG_LOGLEVEL warn
RUN npm i -g serve
CMD serve -s build/app -p 3000
EXPOSE 3000
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build

Image name is <accountId>.dkr.ecr.us-east-1.amazonaws.com/<frontendName>:latest and <accountId>.dkr.ecr.us-east-1.amazonaws.com/<apiName>:latest

I don't know if volume still needs to be declared, or the mountpoints, all I know is I need to put there the version of the dockerrun json to v2 and the name, image and portsmapping in container Definition. Most of the samples are confusing enough since none of them shows an app from private repo and they have those volumes, mountpoints, links, that I don't really understand how to use. I tried the one below but it did not work

{
    "AWSEBDockerrunVersion": 2,
    "containerDefinitions": [
        {
            "name": "imgName",
            "image": "<accountId>.dkr.ecr.<region>.amazonaws.com/<apiName>:latest",
            "memory": 128,
            "portMappings": [
                {
                    "hostPort": 8080,
                    "containerPort": 8080
                }
            ],
            "links": [
                "frontend"
            ]
        },
        {
            "name": "frontend",
            "image": "<accountId>.dkr.ecr.<region>.amazonaws.com/<frontendName>:latest",
            "memory": 128,
            "portMappings": [
                {
                    "hostPort": 3000,
                    "containerPort": 3000
                }
            ]
        }
    ]
}

AWS::CFN::Authentication example issue with custom IamInstanceProfile

This example with AWS::CloudFormation::Authentication will not work in case you are passing custom IAM instance profile with aws:autoscaling:launchconfiguration:IamInstanceProfile option:

  InstanceProfile:
    Type: AWS::IAM::InstanceProfile
    Properties:
      Path: /
      Roles:
      - !Ref InstanceRole
  InstanceRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - ec2.amazonaws.com
          Action:
          - sts:AssumeRole
....
  EBConfigurationTemplate:
    Type: AWS::ElasticBeanstalk::ConfigurationTemplate
    Properties:
      ApplicationName: !Ref EBApplicationName
      SolutionStackName: !Ref EBPlatform
      OptionSettings:
      - Namespace: 'aws:autoscaling:launchconfiguration'
        OptionName: IamInstanceProfile
        Value: !Ref InstanceProfile

As you can see we should specify the instance profile's name or its ARN, but AWS CFN Authentication accepts rolename only. Passing instance profile instead of role name will raise 403 error in eb-activity.log. Same issue occurs several times in this repo.

go-beanstalk-gin

Hey, I just authored a repo which demonstrates setting up a webapp using gin in Elastic Beanstalk - sudo-suhas/go-beanstalk-gin.

Do you think it makes sense to add a link to it in the readme for this repo?

If you have any feedback that'd be great too.

/opt/elasticbeanstalk/bin/get-config doesn't exist for Amazon Linux 2 Platforms

Issue:

In a lot of .ebextensions configurations for Amazon Linux 1.X.X platforms, you can get environment configurations using the following command within bash files:

SOME_VARIABLE=$(/opt/elasticbeanstalk/bin/get-config environment -k 'ENV_VARIABLE_KEY')

For Amazon Linux 2, this command has been removed (from what I can tell)

TL;DR

The file /opt/elasticbeanstalk/bin/get-config environment is missing from Amazon Linux 2. To reproduce some functionality like so, we can use the output from calling/opt/aws/bin/cfn-get-metadata.

Possible Solution:

After some inspection in the logs, I was able to deduce that you can still access environment variables, but from using a different command:

  • /opt/aws/bin/cfn-get-metadata

There was a specific log entry that tipped me off to this, which I'll omit from showing here but you can quickly find it by looking for the command in the log file /var/log/eb-engine.log.

I was able to get environment variables in the following way:

  1. Gather the Environment Region and Stack ID
  2. Pass those values to /opt/aws/bin/cfn-get-metadata to get environment variables
# --------------------------------------------------
# HOW TO GET ENVIRONMENT VARIABLES
# --------------------------------------------------

# Get the Region
ENV_REGION="$(</opt/elasticbeanstalk/config/ebenvinfo/region)"

# Get the Stack ID
ENV_STACK_ID="$(</opt/elasticbeanstalk/config/ebenvinfo/stackid)"

# Pass the variables to the CloudFormation Meta Data command.
# Pipe the data to JQ to reduce the environment variables array to an actual key value map
ENV_VARS_KWARGS="$(sudo /opt/aws/bin/cfn-get-metadata -s $ENV_STACK_ID -r AWSEBBeanstalkMetadata --region $ENV_REGION -k "AWS::ElasticBeanstalk::Ext.Parameters.EnvironmentVariables" | jq -c '. |= reduce (.[] | split("=")) as [$key, $value] ({}; .[$key] = $value)')"

# Access any environment variable like so
MY_VARIABLE_VALUE=$(jq -r '.MY_VARIABLE_KEY' <<< $ENV_VARS_KWARGS)

Conclusion

I feel like this isn't an optimal solution, but was able to give me what I needed relative to what I was able to find though my own inspection.

Closing Thoughts

I have some final thoughts for other people that may help to elaborate more on what the optimal solution for this could be:

  1. I realized the file /opt/elasticbeanstalk/config/ebenvinfo/env is temporarily written during the build process. Exposing or extending the same script that builds this file may produce the missing functionality from Amazon Linux v1's /opt/elasticbeanstalk/bin/get-config.
  2. Wrap my initial solution into a platform prebuild hook (.platform/hooks/prebuild) and take the output from ENV_VARS_KWARGS and write it to a file. You could access the file like so:
    # Using JQ
    MY_VARIABLE_VALUE=$(jq -r '.MY_VARIABLE_KEY' <<< /path/to/env_kwargs_saved.json)
    

Sample of IMDSv2 activation

Hi,

Would you mind adding a sample to enable IMDSv2. I know I can activate with the CLI :

aws ec2 run-instances \
    --image-id ami-1a2b3c4d \
    --instance-type c3.large \
    --key-name MyKeyPair \
    --metadata-options "HttpEndpoint=enabled,HttpTokens=required"

But I can't find any resources to do it with ebextensions.

Thanks a lot in advance.

Variables show as variables

Hello,

I am trying to auto deploy aws eb and more services, now the following problem is coming up.
There is no way i get {"Ref" : "AWS::Region"} parsed in one of the .config files, even the sample is still showing the command instead of the value in the env.

Can you support on this ?

Greatings.

Update drupal and wordpress samples to use Nginx.

php 7.4 is only supported by Amazon linux 2 which only supports Nginx. Would be great if there are updates to the samples and docs on how to setup with load balanced auto scaled drupal and wordpress on elastic beanstalk. thanks :)

Cloud watch stream

I want to stream tomcat catalinat.out logs to cloud watch:

This is my onfig :

packages:
yum:
awslogs: []

files:
"/etc/awslogs/awscli.conf":
mode: "000600"
owner: root
group: root
content: |
[plugins]
cwlogs = cwlogs
[default]
region = {"Ref":"AWS::Region"}

"/etc/awslogs/awslogs.conf":
mode: "000600"
owner: root
group: root
content: |
[general]
state_file = /var/lib/awslogs/agent-state

files:
"/etc/awslogs/config/logs.conf":
mode: "000600"
owner: root
group: root
content: |
[/var/log/tomcat8/catalina.out]
log_group_name = {"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "/var/log/tomcat8/catalina.out"]]}
log_stream_name = {instance_id}
file = /var/log/tomcat8/catalina.out

commands:
"01":
command: chkconfig awslogs on
"02":
command: service awslogs restart

But I don't see catalina.out in cloudwatch console :
image

[EFS][Bug] storage-efs-mountfilesystem.config no longer works with alb2

While testing out new php platform I found this to be no longer working.

https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/instance-configuration/storage-efs-mountfilesystem.config

Doesn't work with ALB2.

Checked with latest PHP platform (ALB2, nginx php-fpm), it doesn't mount FS.

Works with legacy ami linux though.

Is there something I am missing ?
Docs just point to this config file

change-nginx-max-body-size.config not working

I added the contents of elastic-beanstalk-samples/configuration-files/aws-provided/instance-configuration/change-nginx-max-body-size.config into a file called 01_nginx.config inside .ebextensions in a java bundle package (zip file via ProcFile).

I'm using Corretto 11 (running on 64bit Amazon Linux 2) and when I make a request I keep getting this error which means that apparently is not working.

<title>413 Request Entity Too Large</title>

413 Request Entity Too Large


nginx/1.16.1

nodejs platform uses upstart not sysVinit

At least in nodejs platform 4.5.0+, nginx is started and stopped with 'initctl' not 'service'

Extensions that need to be modified:
configuration-files/aws-provided/security-configuration/https-redirect/nodejs/https-redirect-nodejs.config
configuration-files/aws-provided/instance-configuration/websockets/nodejs/websockets-nodejs.config

Rather than replacing service nginx stop|start with initctl start|stop nginx, logic needs to be added to detect which one is in use.

With the current https-redirect-nodejs.config, /var/log/eb-activity.log:

[2018-10-17T19:53:16.175Z] INFO  [27164] - [Configuration update xxx] : Activity execution failed, because: + rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
  + service nginx stop
  Stopping nginx: /sbin/service: line 66: $pid Killed                  env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS} (ElasticBeanstalk::ExternalInvocationError)
caused by: + rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
  + service nginx stop
  Stopping nginx: /sbin/service: line 66: $pid Killed                  env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS} (Executor::NonZeroExitStatus)

SQS with https redirect (Rails/Puma)

Running RoR 5.1 with the following config:
https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/security-configuration/https-redirect/ruby-puma/https-redirect-ruby-puma.config

I was unable to get the worker tier to consume jobs from SQS. (Error logs show a 301 redirect).

Per worker environments documentation, SQS sends a POST request to http://localhost/

Because of this I believe the current config is redirecting the SQS post.

To fix the issue, modified the config as follows:

location / {
             set $redirect 0;
             if ($http_x_forwarded_proto != "https") {
               set $redirect 1;
             }
             if ($http_user_agent ~* "ELB-HealthChecker") {
               set $redirect 0;
             }
             if ($http_user_agent ~* "aws-sqsd") {
               set $redirect 0;
             }
             if ($redirect = 1) {
               return 301 https://$host$request_uri;
} 

I was able to solve my issue by checking for the SQS user agent. Wonder if this should be included in the sample config files by default?

alb-http-to-https-redirection.config: Contains invalid key: 'Path'.

Elastic beanstalk event error: Error processing file (Skipping): DEV/Package/PackageTmp/bin/.ebextensions/alb-http-to-https-redirection-full.config' - Contains invalid key: 'Path'.

Environment:
Platform branch
IIS 10.0 running on 64bit Windows Server 2019
Current platform version
2.5.2

I followed the instructions and setup the prerequisite 443 listener for my Application load balancer in elastic beanstalk.

Everything on my application works except the redirect from http to https.

remove jq as a dependency for `get-config environment` commands

The examples on this repo use JQ to pull out specific fields in calls to get-config:

$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.MOUNT_DIRECTORY')

I wasted some time figuring out that not only is JQ not installed by default on most platforms, but you don't need it if you use -k

$(/opt/elasticbeanstalk/bin/get-config environment -k MOUNT_DIRECTORY)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.