Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
Cloudformation S3bucket creation

Here's the cloudformation template I wrote to create a simple S3 bucket, How do I specify the name of the bucket? Is this the right way?

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Simple S3 Bucket",
  "Parameters": {
    "OwnerService": {
      "Type": "String",
      "Default": "CloudOps",
      "Description": "Owner or service name. Used to identify the owner of the vpc stack"
    },
    "ProductCode": {
      "Type": "String",
      "Default": "cloudops",
      "Description": "Lowercase version of the product code (i.e. jem). Used for tagging"
    },
    "StackEnvironment": {
      "Type": "String",
      "Default": "stage",
      "Description": "Lowercase version of the environment name (i.e. stage). Used for tagging"
    }
  },
  "Mappings": {
    "RegionMap": {
      "us-east-1": {
        "ShortRegion": "ue1"
      },
      "us-west-1": {
        "ShortRegion": "uw1"
      },
      "us-west-2": {
        "ShortRegion": "uw2"
      },
      "eu-west-1": {
        "ShortRegion": "ew1"
      },
      "ap-southeast-1": {
        "ShortRegion": "as1"
      },
      "ap-northeast-1": {
        "ShortRegion": "an1"
      },
      "ap-northeast-2": {
        "ShortRegion": "an2"
      }
    }
  },
  "Resources": {
    "JenkinsBuildBucket": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": {
          "Fn::Join": [
            "-",
            [
              {
                "Ref": "ProductCode"
              },
              {
                "Ref": "StackEnvironment"
              },
              "deployment",
              {
                "Fn::FindInMap": [
                  "RegionMap",
                  {
                    "Ref": "AWS::Region"
                  },
                  "ShortRegion"
                ]
              }
            ]
          ]
        },
        "AccessControl": "Private"
      },
      "DeletionPolicy": "Delete"
    }
  },
  "Outputs": {
    "DeploymentBucket": {
      "Description": "Bucket Containing Chef files",
      "Value": {
        "Ref": "DeploymentBucket"
      }
    }
  }
}
about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Here's a really simple Cloudformation template that creates an S3 bucket, including defining the bucketname.

AWSTemplateFormatVersion: '2010-09-09'
Description: create a single S3 bucket

Resources:
  SampleBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: sample-bucket-0827-cc

You can also leave the "Properties: BucketName" lines off if you want AWS to name the bucket for you. Then it will look like $StackName-SampleBucket-$uniqueIdentifier.

Hope this helps.

about 4 years ago · Santiago Trujillo Relatório

0

Your code has the BucketName already specified:

"BucketName": {
      "Fn::Join": [
        "-",
        [
          {
            "Ref": "ProductCode"
          },
          {
            "Ref": "StackEnvironment"
          },
          "deployment",
          {
            "Fn::FindInMap": [
              "RegionMap",
              {
                "Ref": "AWS::Region"
              },
              "ShortRegion"
            ]
          }
        ]
      ]
    },

The BucketName is a string, and since you are using 'Fn Join', it will be combined of the functions you are joining. "The intrinsic function Fn::Join appends a set of values into a single value, separated by the specified delimiter. If a delimiter is the empty string, the set of values are concatenated with no delimiter." Your bucket name if you don't change the defaults is: cloudops-stage-deplyment-yourAwsRegion

If you change the default parameters, then both cloudops, and stage can be changed, deployment is hard coded, yourAWSRegion will be pulled from where the stack is running, and will be returned in short format via the Mapping.

about 4 years ago · Santiago Trujillo Relatório

0

To extend 'cloudquiz' answer, this is what it'd look in yaml format:

Resources:
  SomeS3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName:
        Fn::Join: ["-", ["yourbucketname", {'Fn::Sub': '${AWS::Region}'}, {'Fn::Sub': '${Stage}'}]]
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda