AWS OpsWorks -Vorlagenausschnitte - AWS CloudFormation

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

AWS OpsWorks -Vorlagenausschnitte

AWS OpsWorks ist ein Anwendungsverwaltungsservice, der eine Vielzahl von Aufgaben wie Softwarekonfiguration, Anwendungsbereitstellung, Skalierung und Überwachung vereinfacht. AWS CloudFormation ist ein Ressourcenverwaltungsservice, mit dem Sie AWS OpsWorks Ressourcen wie AWS OpsWorks Stacks, Ebenen, Apps und Instances verwalten können.

AWS OpsWorks PHP-Beispiel-App

Die folgende Beispielvorlage stellt eine AWS OpsWorks PHP-Beispielwebanwendung bereit, die im öffentlichen Git-Repository gespeichert ist. Der AWS OpsWorks Stack umfasst zwei Anwendungsserver mit einem Load Balancer, der eingehenden Datenverkehr gleichmäßig auf die Server verteilt. Der AWS OpsWorks Stack enthält auch einen Back-End-MySQL-Datenbankserver zum Speichern von Daten. Weitere Informationen zum Beispiel für die AWS OpsWorks -Anwendung finden Sie unter Walkthrough: Grundlagen AWSAWS OpsWorks zum Erstellen eines Anwendungsserver-Stack im AWS OpsWorks -Benutzerhandbuch.

Anmerkung

Die DefaultInstanceProfileArn Eigenschaften ServiceRoleArn und verweisen auf IAM-Rollen, die nach AWS OpsWorks der ersten Verwendung von erstellt werden.

Das Beispiel definiert den Parameter MysqlRootPassword mit auf true gesetzter Eigenschaft NoEcho. Wenn Sie das NoEchoAttribut auf setzentrue, CloudFormation gibt den als Sternchen (*****) maskierten Parameterwert für alle Aufrufe zurück, die den Stack oder die Stack-Ereignisse beschreiben.

Wichtig

Anstatt vertrauliche Informationen direkt in Ihre CloudFormation Vorlagen einzubetten, empfehlen wir Ihnen, dynamische Parameter in der Stack-Vorlage zu verwenden, um auf vertrauliche Informationen zu verweisen, die außerhalb von gespeichert und verwaltet werden CloudFormation, z. B. im AWS Systems Manager Parameter Store oder AWS Secrets Manager.

Weitere Informationen finden Sie in der Keine Anmeldeinformationen in Vorlagen einbetten bewährten Methode.

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Parameters": { "ServiceRole": { "Default": "aws-opsworks-service-role", "Description": "The OpsWorks service role", "Type": "String", "MinLength": "1", "MaxLength": "64", "AllowedPattern": "[a-zA-Z][a-zA-Z0-9-]*", "ConstraintDescription": "must begin with a letter and contain only alphanumeric characters." }, "InstanceRole": { "Default": "aws-opsworks-ec2-role", "Description": "The OpsWorks instance role", "Type": "String", "MinLength": "1", "MaxLength": "64", "AllowedPattern": "[a-zA-Z][a-zA-Z0-9-]*", "ConstraintDescription": "must begin with a letter and contain only alphanumeric characters." }, "AppName": { "Default": "myapp", "Description": "The app name", "Type": "String", "MinLength": "1", "MaxLength": "64", "AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*", "ConstraintDescription": "must begin with a letter and contain only alphanumeric characters." }, "MysqlRootPassword" : { "Description" : "MysqlRootPassword", "NoEcho" : "true", "Type" : "String" } }, "Resources": { "myStack": { "Type": "AWS::OpsWorks::Stack", "Properties": { "Name": { "Ref": "AWS::StackName" }, "ServiceRoleArn": { "Fn::Join": [ "", ["arn:aws:iam::", {"Ref": "AWS::AccountId"}, ":role/", {"Ref": "ServiceRole"}] ] }, "DefaultInstanceProfileArn": { "Fn::Join": [ "", ["arn:aws:iam::", {"Ref": "AWS::AccountId"}, ":instance-profile/", {"Ref": "InstanceRole"}] ] }, "UseCustomCookbooks": "true", "CustomCookbooksSource": { "Type": "git", "Url": "git://github.com/amazonwebservices/opsworks-example-cookbooks.git" } } }, "myLayer": { "Type": "AWS::OpsWorks::Layer", "DependsOn": "myApp", "Properties": { "StackId": {"Ref": "myStack"}, "Type": "php-app", "Shortname" : "php-app", "EnableAutoHealing" : "true", "AutoAssignElasticIps" : "false", "AutoAssignPublicIps" : "true", "Name": "MyPHPApp", "CustomRecipes" : { "Configure" : ["phpapp::appsetup"] } } }, "DBLayer" : { "Type" : "AWS::OpsWorks::Layer", "DependsOn": "myApp", "Properties" : { "StackId" : {"Ref":"myStack"}, "Type" : "db-master", "Shortname" : "db-layer", "EnableAutoHealing" : "true", "AutoAssignElasticIps" : "false", "AutoAssignPublicIps" : "true", "Name" : "MyMySQL", "CustomRecipes" : { "Setup" : ["phpapp::dbsetup"] }, "Attributes" : { "MysqlRootPassword" : {"Ref":"MysqlRootPassword"}, "MysqlRootPasswordUbiquitous": "true" }, "VolumeConfigurations":[{"MountPoint":"/vol/mysql","NumberOfDisks":1,"Size":10}] } }, "ELBAttachment" : { "Type" : "AWS::OpsWorks::ElasticLoadBalancerAttachment", "Properties" : { "ElasticLoadBalancerName" : { "Ref" : "ELB" }, "LayerId" : { "Ref" : "myLayer" } } }, "ELB" : { "Type": "AWS::ElasticLoadBalancing::LoadBalancer", "Properties": { "AvailabilityZones": { "Fn::GetAZs" : "" } , "Listeners": [{ "LoadBalancerPort": "80", "InstancePort": "80", "Protocol": "HTTP", "InstanceProtocol": "HTTP" }], "HealthCheck": { "Target": "HTTP:80/", "HealthyThreshold": "2", "UnhealthyThreshold": "10", "Interval": "30", "Timeout": "5" } } }, "myAppInstance1": { "Type": "AWS::OpsWorks::Instance", "Properties": { "StackId": {"Ref": "myStack"}, "LayerIds": [{"Ref": "myLayer"}], "InstanceType": "m1.small" } }, "myAppInstance2": { "Type": "AWS::OpsWorks::Instance", "Properties": { "StackId": {"Ref": "myStack"}, "LayerIds": [{"Ref": "myLayer"}], "InstanceType": "m1.small" } }, "myDBInstance": { "Type": "AWS::OpsWorks::Instance", "Properties": { "StackId": {"Ref": "myStack"}, "LayerIds": [{"Ref": "DBLayer"}], "InstanceType": "m1.small" } }, "myApp" : { "Type" : "AWS::OpsWorks::App", "Properties" : { "StackId" : {"Ref":"myStack"}, "Type" : "php", "Name" : {"Ref": "AppName"}, "AppSource" : { "Type" : "git", "Url" : "git://github.com/amazonwebservices/opsworks-demo-php-simple-app.git", "Revision" : "version2" }, "Attributes" : { "DocumentRoot" : "web" } } } } }

YAML

AWSTemplateFormatVersion: '2010-09-09' Parameters: ServiceRole: Default: aws-opsworks-service-role Description: The OpsWorks service role Type: String MinLength: '1' MaxLength: '64' AllowedPattern: "[a-zA-Z][a-zA-Z0-9-]*" ConstraintDescription: must begin with a letter and contain only alphanumeric characters. InstanceRole: Default: aws-opsworks-ec2-role Description: The OpsWorks instance role Type: String MinLength: '1' MaxLength: '64' AllowedPattern: "[a-zA-Z][a-zA-Z0-9-]*" ConstraintDescription: must begin with a letter and contain only alphanumeric characters. AppName: Default: myapp Description: The app name Type: String MinLength: '1' MaxLength: '64' AllowedPattern: "[a-zA-Z][a-zA-Z0-9]*" ConstraintDescription: must begin with a letter and contain only alphanumeric characters. MysqlRootPassword: Description: MysqlRootPassword NoEcho: 'true' Type: String Resources: myStack: Type: AWS::OpsWorks::Stack Properties: Name: Ref: AWS::StackName ServiceRoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/${ServiceRole}" DefaultInstanceProfileArn: !Sub "arn:aws:iam::${AWS::AccountId}:instance-profile/${InstanceRole}" UseCustomCookbooks: 'true' CustomCookbooksSource: Type: git Url: git://github.com/amazonwebservices/opsworks-example-cookbooks.git myLayer: Type: AWS::OpsWorks::Layer DependsOn: myApp Properties: StackId: Ref: myStack Type: php-app Shortname: php-app EnableAutoHealing: 'true' AutoAssignElasticIps: 'false' AutoAssignPublicIps: 'true' Name: MyPHPApp CustomRecipes: Configure: - phpapp::appsetup DBLayer: Type: AWS::OpsWorks::Layer DependsOn: myApp Properties: StackId: Ref: myStack Type: db-master Shortname: db-layer EnableAutoHealing: 'true' AutoAssignElasticIps: 'false' AutoAssignPublicIps: 'true' Name: MyMySQL CustomRecipes: Setup: - phpapp::dbsetup Attributes: MysqlRootPassword: Ref: MysqlRootPassword MysqlRootPasswordUbiquitous: 'true' VolumeConfigurations: - MountPoint: "/vol/mysql" NumberOfDisks: 1 Size: 10 ELBAttachment: Type: AWS::OpsWorks::ElasticLoadBalancerAttachment Properties: ElasticLoadBalancerName: Ref: ELB LayerId: Ref: myLayer ELB: Type: AWS::ElasticLoadBalancing::LoadBalancer Properties: AvailabilityZones: Fn::GetAZs: '' Listeners: - LoadBalancerPort: '80' InstancePort: '80' Protocol: HTTP InstanceProtocol: HTTP HealthCheck: Target: HTTP:80/ HealthyThreshold: '2' UnhealthyThreshold: '10' Interval: '30' Timeout: '5' myAppInstance1: Type: AWS::OpsWorks::Instance Properties: StackId: Ref: myStack LayerIds: - Ref: myLayer InstanceType: m1.small myAppInstance2: Type: AWS::OpsWorks::Instance Properties: StackId: Ref: myStack LayerIds: - Ref: myLayer InstanceType: m1.small myDBInstance: Type: AWS::OpsWorks::Instance Properties: StackId: Ref: myStack LayerIds: - Ref: DBLayer InstanceType: m1.small myApp: Type: AWS::OpsWorks::App Properties: StackId: Ref: myStack Type: php Name: Ref: AppName AppSource: Type: git Url: git://github.com/amazonwebservices/opsworks-demo-php-simple-app.git Revision: version2 Attributes: DocumentRoot: web