Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Extraits de modèle Elastic Beanstalk
Avec Elastic Beanstalk, vous pouvez rapidement déployer et gérer des AWS applications sans vous soucier de l'infrastructure qui exécute ces applications. L'exemple de modèle suivant peut vous aider à décrire les ressources Elastic Beanstalk de votre modèle. AWS CloudFormation
Exemple d'Elastic Beanstalk PHP
L'exemple de modèle suivant déploie un exemple d'application PHP Web stocké dans un compartiment Amazon S3. L'environnement est également un environnement d'auto-scaling et d'équilibrage de charge, avec un minimum de deux EC2 instances Amazon et un maximum de six. Il montre un environnement Elastic Beanstalk qui utilise une ancienne configuration de lancement. Pour plus d'informations sur l'utilisation d'un modèle de lancement à la place, voir Modèles de lancement dans le Guide du AWS Elastic Beanstalk développeur.
Remplacez
par le nom d'une pile de solution (version de plateforme). Pour obtenir la liste des piles de solutions disponibles, utilisez la AWS CLI commandeaws elasticbeanstalk list-available-solution-stacks.solution-stack
JSON
{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "sampleApplication": { "Type": "AWS::ElasticBeanstalk::Application", "Properties": { "Description": "AWS Elastic Beanstalk Sample Application" } }, "sampleApplicationVersion": { "Type": "AWS::ElasticBeanstalk::ApplicationVersion", "Properties": { "ApplicationName": { "Ref": "sampleApplication" }, "Description": "AWS ElasticBeanstalk Sample Application Version", "SourceBundle": { "S3Bucket": { "Fn::Sub": "elasticbeanstalk-samples-${AWS::Region}" }, "S3Key": "php-newsample-app.zip" } } }, "sampleConfigurationTemplate": { "Type": "AWS::ElasticBeanstalk::ConfigurationTemplate", "Properties": { "ApplicationName": { "Ref": "sampleApplication" }, "Description": "AWS ElasticBeanstalk Sample Configuration Template", "OptionSettings": [ { "Namespace": "aws:autoscaling:asg", "OptionName": "MinSize", "Value": "2" }, { "Namespace": "aws:autoscaling:asg", "OptionName": "MaxSize", "Value": "6" }, { "Namespace": "aws:elasticbeanstalk:environment", "OptionName": "EnvironmentType", "Value": "LoadBalanced" }, { "Namespace": "aws:autoscaling:launchconfiguration", "OptionName": "IamInstanceProfile", "Value": { "Ref": "MyInstanceProfile" } } ], "SolutionStackName": "
solution-stack
" } }, "sampleEnvironment": { "Type": "AWS::ElasticBeanstalk::Environment", "Properties": { "ApplicationName": { "Ref": "sampleApplication" }, "Description": "AWS ElasticBeanstalk Sample Environment", "TemplateName": { "Ref": "sampleConfigurationTemplate" }, "VersionLabel": { "Ref": "sampleApplicationVersion" } } }, "MyInstanceRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "ec2.amazonaws.com" ] }, "Action": [ "sts:AssumeRole" ] } ] }, "Description": "Beanstalk EC2 role", "ManagedPolicyArns": [ "arn:aws:iam::aws:policy/AWSElasticBeanstalkWebTier", "arn:aws:iam::aws:policy/AWSElasticBeanstalkMulticontainerDocker", "arn:aws:iam::aws:policy/AWSElasticBeanstalkWorkerTier" ] } }, "MyInstanceProfile": { "Type": "AWS::IAM::InstanceProfile", "Properties": { "Roles": [ { "Ref": "MyInstanceRole" } ] } } } }
YAML
AWSTemplateFormatVersion: '2010-09-09' Resources: sampleApplication: Type: AWS::ElasticBeanstalk::Application Properties: Description: AWS Elastic Beanstalk Sample Application sampleApplicationVersion: Type: AWS::ElasticBeanstalk::ApplicationVersion Properties: ApplicationName: Ref: sampleApplication Description: AWS ElasticBeanstalk Sample Application Version SourceBundle: S3Bucket: !Sub "elasticbeanstalk-samples-${AWS::Region}" S3Key: php-newsample-app.zip sampleConfigurationTemplate: Type: AWS::ElasticBeanstalk::ConfigurationTemplate Properties: ApplicationName: Ref: sampleApplication Description: AWS ElasticBeanstalk Sample Configuration Template OptionSettings: - Namespace: aws:autoscaling:asg OptionName: MinSize Value: '2' - Namespace: aws:autoscaling:asg OptionName: MaxSize Value: '6' - Namespace: aws:elasticbeanstalk:environment OptionName: EnvironmentType Value: LoadBalanced - Namespace: aws:autoscaling:launchconfiguration OptionName: IamInstanceProfile Value: !Ref MyInstanceProfile SolutionStackName:
solution-stack
sampleEnvironment: Type: AWS::ElasticBeanstalk::Environment Properties: ApplicationName: Ref: sampleApplication Description: AWS ElasticBeanstalk Sample Environment TemplateName: Ref: sampleConfigurationTemplate VersionLabel: Ref: sampleApplicationVersion MyInstanceRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: - ec2.amazonaws.com Action: - sts:AssumeRole Description: Beanstalk EC2 role ManagedPolicyArns: - arn:aws:iam::aws:policy/AWSElasticBeanstalkWebTier - arn:aws:iam::aws:policy/AWSElasticBeanstalkMulticontainerDocker - arn:aws:iam::aws:policy/AWSElasticBeanstalkWorkerTier MyInstanceProfile: Type: AWS::IAM::InstanceProfile Properties: Roles: - !Ref MyInstanceRole